I have a nested gridview. On the top-level grid, I have a button that should call a stored procedure and and put that data into the nested gridview.
Here is my ASPX page code
<form id="form1" runat="server">
<asp:GridView ID="gvCustomers" runat="server" AutoGenerateColumns="false" CssClass="Grid"
DataKeyNames="ID" OnRowDataBound="OnRowDataBound">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button Text="Expand" runat="server" OnClick="Select" CommandArgument='<%#Eval("ID") %>' />
<asp:Panel ID="pnlOrders" runat="server" Style="display: none">
<asp:GridView ID="gvOrders" runat="server" AutoGenerateColumns="false" CssClass = "ChildGrid">
<Columns>
<asp:BoundField ItemStyle-Width="135px" DataField="Label" HeaderText="Label" />
<asp:BoundField ItemStyle-Width="150px" DataField="IDs" HeaderText="IDs" />
<asp:BoundField ItemStyle-Width="150px" DataFormatString="${0:###,###,###.00}" DataField="Total" HeaderText=Total" />
</Columns>
</asp:GridView>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField ItemStyle-Width="150px" DataField="Source" HeaderText="Source" />
<asp:BoundField ItemStyle-Width="150px" DataField="Label" HeaderText="Label" />
<asp:BoundField ItemStyle-Width="150px" DataFormatString="${0:###,###,###.00}" DataField="Total20" HeaderText="Total20" />
<asp:BoundField ItemStyle-Width="150px" DataFormatString="${0:###,###,###.00}" DataField="Total1" HeaderText="Total1" />
<asp:BoundField ItemStyle-Width="150px" DataFormatString="{0:P1}" DataField="Average_Fee_PCT" HeaderText="Average Fee" />
</Columns>
</asp:GridView>
</form>
Here is my C# code
protected void Select(object sender, EventArgs e)
{
string ID = (sender as Button).CommandArgument;
Response.Write("<script>console.log('ID...." + ID + "');</script>");
GridView gvOrders = e.Row.FindControl("gvOrders") as GridView;
gvOrders.DataSource = GetData(string.Format("exec ReturnDataSingle '" + ID + "', '"+ DateTime.Now.ToString("yyyy-MM-dd") + "'"));
gvOrders.DataBind();
}
Here is the error message I am getting
'System.EventArgs' does not contain a definition for 'Row' and no extension method 'Row' accepting a first argument of type 'System.EventArgs' could be found
Can someone help me figure out how I would be able to add the stored procedure data to the gvOrders gridview based off that button click?
What I have tried:
I can't seem to figure out how to add that data into the table from the button click.