The results of a database query produce button controls. I am trying to produce a RowCommand event that is able to perform some logic on the record the button control is referring to.
I was wondering how i could put data into the text attribute of labels.
Here is my asp.net code:
<asp:GridView ID="QueryPaneResults" runat="server" AutoGenerateColumns="False" DataSourceID="QueryData" AllowPaging="True" >
<Columns>
<asp:TemplateField SortExpression="OrgName" >
<ItemTemplate>
<asp:Button ID="btnOrg" runat="server" Text='<%# Bind("OrgName") %>' CommandName="SelectionData" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" ></asp:Button>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="QueryData" runat="server" ConnectionString="<%$ ConnectionStrings:dbca %>" SelectCommand="SELECT * FROM [Organization]"></asp:SqlDataSource>
Next is my C# code
protected void QueryPaneResults_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "SelectionData")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = QueryPaneResults.Rows[index];
}
}
This is the point where I am stuck. I cannot figure how to put the results into a variables.
I cannot get the RowCommand event to do anything.
Any help would be highly appreciated!!

New Topic/Question
Reply



MultiQuote




|