mark up and code I am binding to the gridview after a search button is clicked. It was working for a while but then it stopped and I don't know what I did to break it. I am not binding anything on the Page Load I was originally trying to Ajax afy the Gridview.
protected void gvParticipantResults_RowCommand(object sender, GridViewCommandEventArgs e)
{
string strCommand = e.CommandName.ToString();
if (strCommand == "Select")
{
int row = Convert.ToInt32(e.CommandArgument);
// setting the selected row to yellow to show whome they are working with
gvParticipantResults.Rows[row].BackColor = Color.Yellow;
// getting the participant ID
ParticipantID = Convert.ToInt32(gvParticipantResults.DataKeys[row].Value);
}
else if (strCommand == "XXXX")
{
strCommand = "SELECT";
}
}
protected void gvParticipantResults_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
// Set the index of the new display page.
gvParticipantResults.PageIndex = e.NewPageIndex;
// Rebind the GridView control to
// show data in the new page.
// BindGridView();
}
<asp:GridView ID="gvParticipantResults" runat="server" Height="125px"
BorderColor="Black" DataKeyNames="ParticipantID"
Width="200px" CellPadding="4" GridLines="Both"
onrowcommand="gvParticipantResults_RowCommand"
onselectedindexchanged="btnSearchParticipant_Click"
ForeColor="#333333" AutoGenerateColumns="False"
AllowPaging="True" PageSize = "10"
onpageindexchanging="gvParticipantResults_PageIndexChanging">
<PagerSettings NextPageText="Next &gt;" />
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<Columns>
<asp:ButtonField Text="Select" CommandName="Select" ButtonType="Button" CausesValidation = "false" />
<asp:BoundField DataField="ParticipantID" HeaderText="ParticipantID" SortExpression="ParticipantID" Visible = "false" />
<asp:BoundField DataField="IsActive" HeaderText="IsActive" SortExpression="IsActive" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="MiddleName" HeaderText="MiddleName" SortExpression="MiddleName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="Gender" HeaderText="Gender" SortExpression="Gender" />
<asp:BoundField DataField="DateOfBirth" HeaderText="DateOfBirth" SortExpression="DateOfBirth" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
</Columns>
<FooterStyle BackColor="#990000" ForeColor="White" Font-Bold="True" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>