Hello all,
I am using c#.net
I have a gridview which needs to contain a 'Use' button (appointmentId set as the commandargument).
Source Code
<asp:GridView ID="resultsReturned" runat="server" AllowPaging="True"
AutoGenerateColumns="False"
EnableSortingAndPagingCallbacks="True"
OnPageIndexChanged="resultsReturned_PageIndexChanged"
onrowcommand="resultsReturned_RowCommand">
<Columns>
<asp:BoundField DataField="UserAppointmentId" HeaderText="App ID" />
<asp:BoundField DataField="UserBookingName" HeaderText="Booking Name" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button runat="server"
ID="UseButton"
Text="Use"
CommandName="Use"
CommandArgument="UserAppointmentId" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Code-Behind
protected void resultsReturned_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Use")
{
correctAppointmentID.Value = (e.CommandArgument.ToString());
}
}
This is used for the pagination:
private void BindAppointments()
{
var results = appointmentRepos.GetBookingIdBySearchCriteria(catgoryid, resultsReturned.PageIndex * resultsReturned.PageSize, -1);
resultsReturned.DataSource = results;
resultsReturned.DataBind();
}
I am binding the appointments to the gridview within the PageLoad/search_Click
This is the error I am receiving:
Callbacks are not supported on TemplateField because some controls cannot update properly in a callback. Turn callbacks off on 'resultsReturned'.
Thanks in advance for any help
Clare