|
-
Sep 27th, 2005, 01:59 PM
#1
Thread Starter
Fanatic Member
Using button code on a datagrid
I need to put buttons in a datagrid. I know how to do this with the
<templatecolumn> , but my question is how do I access it in the
codebehind .vb file, if the number of buttons is variable? I need to put some
code in the _Click event of each button.
-
Sep 28th, 2005, 12:22 AM
#2
New Member
Re: Using button code on a datagrid
Hi,
Try this code. Here is the code for how to put Radio Button in Datagrid, and how to select the perticular row which is clicked is given..
<asp:TemplateColumn>
<ItemTemplate>
<asp:RadioButton AutoPostBack="True" id="rbSel" OnCheckedChanged="SelectOpt" runat="server"></asp:RadioButton>
</ItemTemplate>
</asp:TemplateColumn>
-------------------------------------------------------------------------
public void SelectOpt(object sender,EventArgs e)
{
System.Web.UI.WebControls.RadioButton rb = new System.Web.UI.WebControls.RadioButton();
rb = (System.Web.UI.WebControls.RadioButton) sender;
sRbText = rb.ClientID;
foreach (DataGridItem i in Dg.Items )
{
rb = (System.Web.UI.WebControls.RadioButton) i.FindControl ("rbSel");
rb.Checked = false;
if (sRbText==rb.ClientID)
{
rb.Checked = true;
//txtSiraNo.Text = rb.Text.Trim();
// if you want to get a property of the selected id
Dg.SelectedIndex =i.ItemIndex;
}
}
}
Regards,
Dharmi
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|