Datagrid Problem
-
hi all i have a problem please suggest me the solution i have a datagrid which consists of bounded columns i need to get the column number or column index datagrid sample is like this where heading channel and corporate are link buttons dynamically displayed slno | region Name |channel | corporate| 1 | abc |ruleset | forapproval 2 | a23 |ruleset | forapproval 3 | 2asdas |ruleset | forapproval 4 | adas |ruleset | forapproval so when i click on channel->ruleset i need to get the column no as 2.. based updon the column number i need to display the details if 2 then channel details else corporate details please .. its very urgent
-
hi all i have a problem please suggest me the solution i have a datagrid which consists of bounded columns i need to get the column number or column index datagrid sample is like this where heading channel and corporate are link buttons dynamically displayed slno | region Name |channel | corporate| 1 | abc |ruleset | forapproval 2 | a23 |ruleset | forapproval 3 | 2asdas |ruleset | forapproval 4 | adas |ruleset | forapproval so when i click on channel->ruleset i need to get the column no as 2.. based updon the column number i need to display the details if 2 then channel details else corporate details please .. its very urgent
Hi, I would make the column ruleset a LinkButton. In your aspx you create a TemplateField that has a LinkButton like:
<asp:LinkButton runat="server" ID="lbRuleSet" CommandName="EditGrid" OnCommand="Grid_OnCommand" />
In the codebehind you create a Method like:
protected void Grid_OnCommand(Object sender, CommandEventArgs e) { LinkButton btn = (LinkButton)sender; GridViewRow row = (GridViewRow)btn.NamingContainer; if (e.CommandName.Equals("EditGrid")) { MyGridView.SelectedIndex = row.RowIndex; // now you have MyGridView.SelectedValue available and you can // display your details, as I believe you want to now the row the // user selected in stead of the clumnnumber it clicked MyGridView.SelectedIndex = -1; //to have no selectedrow again } }