So the problem I have is being able to get the value from the <asp:buttonfield /> I am using now and running a query based on this.
I want when I postback to have a sql query and a gridview generated based on the string passed from the button click.
example:
<asp: Panel ID="Option1" runat="server" Visible="False">
<asp: GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1"
EmptyDataText="There are no data records to display."
onselectedindexchanged="GridView1_SelectedIndexChanged">
<Columns>
<asp: ButtonField DataTextField="Option1" />
</Columns>
</asp: GridView>
<asp: SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings: DB1ConnectionString1 %>"
ProviderName="<%$ ConnectionStrings: DB1ConnectionString1.ProviderName %>"
SelectCommand="SELECT distinct [Option1] FROM [Tablename]">
</asp: SqlDataSource>
</asp: Panel>
/* I want to be able to run a query based on the data passed in from the buttonfield eg:
If the value is "Peter"
I want to be able to generate and run a query based on that.
(As it sits I cant even figure out how to get the value from the buttonfield)
*/
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
/*
expected code
1) read the value from the button field
2) set an sql query using that value as the where qualifier
3) Bind the data output to another gridview
*/
}
I really appreciate any help or pointers I can get as this is my first week with .net and c# all the help I can get is truly welcome.