<asp:Label id='Label1' runat='server'>Label</asp:Label>
<asp:DataGrid id='DataGrid1' OnSelectedIndexChanged='SelectedIndexChg' AutoGenerateColumns='False' runat='server'>
<Columns>
<asp:ButtonColumn Text='Select' ButtonType='PushButton' CommandName='Select'></asp:ButtonColumn>
<asp:TemplateColumn HeaderText='ProductId'>
<ItemTemplate>
<asp:Label text=<%#DataBinder.Eval(Container.DataItem , 'Productid')%> ID='lbl1' Runat=server ></asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
VB.NET
Protected Sub SelectedIndexChg(ByVal sender As Object, ByVal e As System.EventArgs)
Label1.Text = CType(DataGrid1.SelectedItem.FindControl('lbl1'), Label).Text
End Sub
C#
protected void SelectedIndexChg(object sender, System.EventArgs e)
{
Label1.Text = ((Label)DataGrid1.SelectedItem.FindControl ('lbl1')).Text ;
}
Share with