0
<asp:GridView ID="GridView1" runat="server" style="width: 615px; margin: 30px;" class="table table-hover table-bordered" AutoGenerateSelectButton="true" OnSelectedIndexChanging="GridView1_SelectedIndex2"></asp:GridView>

protected void GridView1_SelectedIndex2(object sender, GridViewSelectEventArgs e)
{
    txtLastName.Text = GridView1.Rows[e.NewSelectedIndex].Cells[3].Text;
    txtFirstName.Text = GridView1.Rows[e.NewSelectedIndex].Cells[2].Text;
}

Based on above code, I generate data in the GridView, and supposedly, when I clicked one of the rows in GridView, the data will be displayed in each textbox based on the cells in each rows.

From what I looked up from the sources, I found the codes that use select button only. and I want to display data without select button.

So, somebody can help me?

Anne
  • 1
  • 3
  • You can use datagridview selection change event for this refer this https://stackoverflow.com/a/11293450/795683 – Sain Pradeep Sep 26 '18 at 05:17
  • but that one is using windows.forms. is it work for me? – Anne Sep 26 '18 at 05:22
  • Please refer this for gridview https://www.aspsnippets.com/Articles/Selecting-GridView-Row-by-clicking-anywhere-on-the-Row.aspx – Sain Pradeep Sep 26 '18 at 05:30
  • @SainPradeep I already followed what you gave me at the above comment. But, i still can't select the row. and also, one of the cells in the row GridView is missing. – Anne Sep 26 '18 at 06:08
  • can you please add your complete code for designer and code behind – Sain Pradeep Sep 26 '18 at 06:30
  • Sorry, I did some silly mistakes. It is already corrected. Thank you @SainPradeep – Anne Sep 26 '18 at 07:18

0 Answers0