</asp:label><asp:datagrid id="DataGrid3" runat="server"
cssclass="DataGrid" showfooter="True"
onupdatecommand="DataGrid3_Update"ondeletecommand= "DataGrid3_Delete"
oneditcommand="DataGrid3_Edit" oncancelcommand="DataGrid3_Cancel"
caption="Pricing Schedules" autogeneratecolumns="False"
OnItemDataBound="ItemDataBoundEventHandler">
<alternatingitemstyle cssclass="DataGrid_AlternatingItemStyle" />
<columns>
<asp:templatecolumn footerstyle-cssclass="DataGrid_FooterStyle"
headerstyle-cssclass="DataGrid_HeaderStyle"
headertext="Description" itemstyle-cssclass="DataGrid_ItemStyle">
<itemtemplate>
<asp:label id="Label1" runat="server" text='<%#
DataBinder.Eval(Container.DataItem, "Description") %>' />
</itemtemplate>
<footertemplate>
<asp:textbox id="TextBox1" maxlength="50" runat="server" />
</footertemplate>
<edititemtemplate>
<asp:textbox id="Textbox13" runat="server" text='<%#
DataBinder.Eval(Container.DataItem, "ID") %>' visible="False" />
<asp:TextBox id="TextBox2" maxlength="50" runat="server" text='<%#
DataBinder.Eval(Container.DataItem, "Description") %>' />
</edititemtemplate>
</asp:templatecolumn>
<asp:editcommandcolumn buttontype="PushButton" canceltext="Cancel"
edittext="Edit" footerstyle-cssclass="DataGrid_FooterStyle"
footerstyle-horizontalalign="Center"
headerstyle-cssclass="DataGrid_HeaderStyle"
itemstyle-cssclass="DataGrid_ItemStyle"
itemstyle-horizontalalign="Center" updatetext="Update" />
<asp:templatecolumn footerstyle-cssclass="DataGrid_FooterStyle"
footerstyle-horizontalalign="Center"
headerstyle-cssclass="DataGrid_HeaderStyle"
itemstyle-cssclass="DataGrid_ItemStyle"
itemstyle-horizontalalign="Center">
<itemtemplate>
<asp:button commandargument='<%#
DataBinder.Eval(Container.DataItem, "ID") %>' commandname="Delete"
id="Button1" runat="server" text="Delete" />
</itemtemplate>
<footertemplate>
<asp:button commandname="Add" id="Button2" runat="server"
text="Add" />
</footertemplate>
<edititemtemplate>
<asp:button commandargument='<%#
DataBinder.Eval(Container.DataItem, "ID") %>' commandname="Delete"
id="Button3" runat="server" text="Delete" />
</edititemtemplate>
</asp:templatecolumn>
</columns>
<edititemstyle cssclass="DataGrid_EditItemStyle" />
<selecteditemstyle cssclass="DataGrid_SelectedItemStyle" />
</asp:datagrid>
next data grid
<asp:datagrid id="DataGrid4" runat="server" cssclass="DataGrid"
showfooter="True" onupdatecommand="DataGrid4_Update"
ondeletecommand="DataGrid4_Delete" oneditcommand="DataGrid4_Edit"
oncancelcommand="DataGrid4_Cancel" caption="Custom Prices"
autogeneratecolumns="False"
onItemDataBound="ItemDataBoundEventHandler_DataGri d4">
<alternatingitemstyle cssclass="DataGrid_AlternatingItemStyle" />
<columns>
<asp:templatecolumn footerstyle-cssclass="DataGrid_FooterStyle"
headerstyle-cssclass="DataGrid_HeaderStyle"
headertext="Product" itemstyle-cssclass="DataGrid_ItemStyle">
<itemtemplate>
<asp:label id="Label5" runat="server" text='<%#
DataBinder.Eval(Container.DataItem, "ProductName") %>' />
</itemtemplate>
<footertemplate>
<asp:dropdownlist datasource="<%# getProductIDs() %>"
datatextfield="ProductName" datavaluefield="ProductID"
id="DropDownList1" runat="server" />
</footertemplate>
<edititemtemplate>
<asp:dropdownlist datasource="<%# getProductIDs() %>"
datatextfield="ProductName" datavaluefield="ProductID"
id="Dropdownlist2" runat="server" selectedvalue='<%#
DataBinder.Eval(Container.DataItem, "ProductID") %>' />
</edititemtemplate>
</asp:templatecolumn>
<asp:templatecolumn footerstyle-cssclass="DataGrid_FooterStyle"
footerstyle-horizontalalign="Right"
headerstyle-cssclass="DataGrid_HeaderStyle"
headerstyle-horizontalalign="Right" headertext="Price"
itemstyle-cssclass="DataGrid_ItemStyle"
itemstyle-horizontalalign="Right">
<itemtemplate>
<asp:label id="Label8" runat="server" text='<%#
DataBinder.Eval(Container.DataItem, "Price", "{0:c}") %>' />
</itemtemplate>
<footertemplate>
<asp:textbox cssclass="currency" columns="3" id="TextBox9"
runat="server" />
</footertemplate>
<edititemtemplate>
<asp:TextBox cssclass="currency" columns="3" id="TextBox10"
runat="server" text='<%# DataBinder.Eval(Container.DataItem, "Price",
"{0:c}") %>' />
</edititemtemplate>
</asp:templatecolumn>
<asp:templatecolumn footerstyle-cssclass="DataGrid_FooterStyle"
footerstyle-horizontalalign="Right"
headerstyle-cssclass="DataGrid_HeaderStyle"
headerstyle-orizontalalign="Right" headertext="Shipping"
itemstyle-cssclass="DataGrid_ItemStyle"
itemstyle-horizontalalign="Right">
<itemtemplate>
<asp:label id="Label9" runat="server" text='<%#
DataBinder.Eval(Container.DataItem, "Shipping", "{0:c}") %>' />
</itemtemplate>
<footertemplate>
<asp:textbox cssclass="currency" columns="3" id="TextBox11"
runat="server" />
</footertemplate>
<edititemtemplate>
<asp:TextBox cssclass="currency" columns="3" id="TextBox12"
runat="server" text='<%# DataBinder.Eval(Container.DataItem,
"Shipping", "{0:c}") %>' />
</edititemtemplate>
</asp:templatecolumn>
<asp:editcommandcolumn buttontype="PushButton" canceltext="Cancel"
edittext="Edit" footerstyle-cssclass="DataGrid_FooterStyle"
footerstyle-horizontalalign="Center"
headerstyle-cssclass="DataGrid_HeaderStyle"
itemstyle-cssclass="DataGrid_ItemStyle"
itemstyle-horizontalalign="Center" updatetext="Update" />
<asp:templatecolumn footerstyle-cssclass="DataGrid_FooterStyle"
footerstyle-horizontalalign="Center"
headerstyle-cssclass="DataGrid_HeaderStyle"
itemstyle-cssclass="DataGrid_ItemStyle"
itemstyle-horizontalalign="Center">
<itemtemplate>
<asp:button commandargument='<%# DataBinder.Eval(Container.DataItem,
"ID") %>' commandname="Delete" id="Button5" runat="server"
text="Delete" />
</itemtemplate>
<footertemplate>
<asp:button commandname="Add" id="Button4" runat="server" text="Add"
/>
</footertemplate>
<edititemtemplate>
<asp:button commandargument='<%# DataBinder.Eval(Container.DataItem,
"ID") %>' commandname="Delete" id="Button6" runat="server"
text="Delete" />
</edititemtemplate>
</asp:templatecolumn>
</columns>
<edititemstyle cssclass="DataGrid_EditItemStyle" />
<selecteditemstyle cssclass="DataGrid_SelectedItemStyle" />
</asp:datagrid>
Code Behind
private void DataGrid3_ItemCommand(Object sender,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (e.CommandName == "Add")
{
sID = Request["id"];
TextBox T1 = (TextBox)e.Item.FindControl("TextBox1");
TextBox T3 = (TextBox)e.Item.FindControl("TextBox3");
TextBox T5 = (TextBox)e.Item.FindControl("TextBox5");
CheckBox C1 = (CheckBox)e.Item.FindControl("CheckBox1");
TextBox T15 = (TextBox)e.Item.FindControl("TextBox15");
RCUserPriceSchedule oUserPriceSchedule = new RCUserPriceSchedule();
oUserPriceSchedule.AuthorityID = Convert.ToString(Session["UserID"]);
oUserPriceSchedule.AccountID = sID;
oUserPriceSchedule.Description = T1.Text;
oUserPriceSchedule.UsesRemaining = Convert.ToInt32(T3.Text);
if (T5.Text != "")
oUserPriceSchedule.EndDate = Convert.ToDateTime(T5.Text);
oUserPriceSchedule.FlatRate = C1.Checked;
oUserPriceSchedule.MaxUses = Convert.ToInt32(T15.Text);
if (!oUserPriceSchedule.DBInsert(sConnection))
{
LabelCustomPricing.ForeColor = System.Drawing.Color.Red;
LabelCustomPricing.Text = "Could not save new pricing schedule: " +
oUserPriceSchedule.ErrorMessage;
}
else
{
getUserPriceScheduleList();
Response.Redirect("/accounts/accountdetails.aspx?id="+sID);
}
}
}
private void getUserPriceScheduleList()
{
sID = Request["id"];
RCUserPriceScheduleList oUserPriceScheduleList = new
RCUserPriceScheduleList();
oUserPriceScheduleList.AuthorityID =
Convert.ToString(Session["UserID"]);
if
(!oUserPriceScheduleList.DBBuildAccountScheduleLis t(sID,sConnection))
{
LabelCustomPricing.ForeColor = System.Drawing.Color.Red;
LabelCustomPricing.Text = "Could not load custom pricing schedule: "
+ oUserPriceScheduleList.ErrorMessage;
}
else
{
oUserPriceScheduleListDataTable =
oUserPriceScheduleList.RCDataTable;
populateDataGrid(DataGrid3, oUserPriceScheduleListDataTable);
}
return;
}
private void populateDataGrid(DataGrid sDataGridName, DataTable
sDataTableName)
{
sDataGridName.DataSource = sDataTableName;
sDataGridName.DataBind();
return;
}
protected void DataGrid3_Edit(Object sender , DataGridCommandEventArgs
e)
{
DataGrid3.EditItemIndex = e.Item.ItemIndex;
DataGrid3.ShowFooter = false;
getUserPriceScheduleList();
}
Above are the relevant methods for the datagrid 3.
When i click the edit button of datagrid3, the Price and Shipping
column of the Datagrid4 display blank fields.
The two datagrids are not related.
Been trying to find the problem, but have no clue.