I am creating a custom web application for our online portal. I am using C# to code this application and I am having a problem with my data grid. I can get the data to display on the datagrid, but when I select the edit command the value (Student ID Number) is one off. For example if I select the first item on the datagrid to edit and pulls the key information of the next one down on the datagrid.
Here is the datagrid code. Please note that the groupedgrid is a custom function using the datagrid that was developed by our online portal product developer but uses the same properties:
<common:groupedgrid id="grdSearchResults" RenderGroupHeaders="True" runat="server" GridLines="None"
HeaderRightColumns="(Colle
ction)" allowsorting="True" allowpaging="True" PagerStyle-Mode="NumericPa
ges"
PagerStyle-HorizontalAlign
="Right" RenderTableFooters="True" ShowFooter="True" DataKeyField="ID_NUM">
<Columns>
<common:EditButtonColumn ToolTipKey="" TextKey="" HeaderText="View"></common
:EditButto
nColumn>
<asp:TemplateColumn SortExpression="NM.ID_NUM"
HeaderText="ID Number">
<ItemTemplate>
<%# DataBinder.Eval(Container.
DataItem,"
ID_NUM") %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="NM.FIRST_N
AME" HeaderText="First Name">
<ItemTemplate>
<%# DataBinder.Eval(Container.
DataItem,"
FIRST_NAME
") %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="NM.LAST_NA
ME" HeaderText="Last Name">
<ItemTemplate>
<%# DataBinder.Eval(Container.
DataItem,"
LAST_NAME"
) %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="DOB">
<ItemTemplate>
<%# DataBinder.Eval(Container.
DataItem,"
DOB") %>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn SortExpression="BM.GENDER"
HeaderText="Gender">
<ItemTemplate>
<%# DataBinder.Eval(Container.
DataItem,"
GENDER") %>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle HorizontalAlign="Right" Mode="NumericPages"></Page
rStyle>
</common:groupedgrid>
Here is the code behind for the edit function:
private void grdSearchResults_EditComma
nd(object source, System.Web.UI.WebControls.
DataGridCo
mmandEvent
Args e)
{
this.ParentPortlet.Portlet
ViewState[
"ID_NUM"] = grdSearchResults.DataKeys[
e.Item.Ite
mIndex].To
String();
//Label1.Text = grdSearchResults.DataKeys[
e.Item.Ite
mIndex].To
String();
//Response.Write(grdSearch
Results.Da
taKeys[e.I
tem.ItemIn
dex]);
this.ParentPortlet.NextScr
een("Stude
nt_Detail"
);
I have used this method in the past and it has worked perfectly.
Thanks for any assistance!
Bill
Start Free Trial