Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to populate multiple textboxes from a row in gridview that uses a link button
    primarykey
    data
    text
    <p>I'm trying to populate multiple text boxes with data from a gridview when I click the link button (which is in fact the name of one of the fields in each row) but it isn't going through. I'm new to this - literally my first time. Any help would be most appreciated. </p> <pre><code>protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow selectedRow = GridView1.Rows[index]; AccountNumber.Text = selectedRow.Cells[1].Text; Name.Text = selectedRow.Cells[1].Text; Address1.Text = selectedRow.Cells[1].Text; Address2.Text = selectedRow.Cells[2].Text; Address3.Text = selectedRow.Cells[3].Text; PhoneNumber.Text = selectedRow.Cells[4].Text; FaxNumber.Text= selectedRow.Cells[5].Text; CurrencyID.Text = selectedRow.Cells[6].Text; } } </code></pre> <hr> <pre><code>&lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Agent_Account_No" DataSourceID="SqlDataSource1" AlternatingRowStyle-BackColor ="Lavender" HeaderStyle-BackColor="#9966FF" AllowSorting="True" HeaderStyle-BorderColor="Black" HorizontalAlign="Center" RowStyle-BorderColor="Black" EmptyDataText="There are no data records to display." onrowcommand ="GridView1_RowCommand"&gt; &lt;AlternatingRowStyle BackColor="#CCFFCC" /&gt; &lt;Columns&gt; &lt;asp:BoundField datafield="Agent_Account_No" HeaderText="Account No" ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Middle" ItemStyle-Width="50" SortExpression="Agent_Account_No" ReadOnly="true"&gt; &lt;ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="50px" /&gt; &lt;/asp:BoundField&gt; &lt;asp:TemplateField HeaderText="Name" SortExpression="Agent_Name"&gt; &lt;ItemTemplate&gt; &lt;asp:LinkButton ID="AgentName" runat="server" Text='&lt;%# Eval("Agent_Name") %&gt;' CommandName="Select" CommandArgument='&lt;%#Bind("Agent_Name") %&gt;'&gt; &lt;/asp:LinkButton&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload