<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:BoundColumn Headertext='ProductId' DataField='Productid'></asp:BoundColumn>
<asp:BoundColumn Headertext='ProductName' DataField='ProductName'></asp:BoundColumn>
</Columns>
</asp:DataGrid>
VB.NET
Protected Sub SelectedIndexChg(ByVal sender As Object, ByVal e As System.EventArgs)
Label1.Text = DataGrid1.SelectedItem.Cells(1).Text & DataGrid1.SelectedItem.Cells(2).Text
End Sub
C#
protected void SelectedIndexChg(object sender, System.EventArgs e)
{
Label1.Text = DataGrid1.SelectedItem.Cells[1].Text + DataGrid1.SelectedItem.Cells[2].Text ;
}
Share with