473,471 Members | 1,716 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

weird DataGrid Behavior

</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.

Nov 17 '05 #1
0 1639

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
0
by: Greenwich Support | last post by:
Hi All, I have a very weird problem which is occurring with a VB.Net app and PostgreSQL 7.3.1. There is a form that has a standard .Net datagrid on it that contains some data from a table in...
1
by: Jonathan Yong | last post by:
I observe a very weird behavior when dynamically create web control and bind events to it. Create a C# ASP.NET application, Put a PlaceHolder and Textbox onto the Web form, and try with the 4...
0
by: MrNobody | last post by:
hey guys... I'm trying to make my DataGrid have selection behavior similar to WindowsExplorer, where I can hold CTRL to add rows to a multi-row selection. Thanks to someone else on this...
1
by: MrNobody | last post by:
Is it at all possible to override the default behavior of a DataGrid when the mouse is clicked on a row? I am having a problem where I am trying to select multiple rows in a DataGrid by...
4
by: Paul | last post by:
I sometimes get a timeout error when populating my datagrid, the code is WizardConnection.Open() UpdateCommand.CommandText = "EXECUTE sp_assign_user '" & PhysOffice.SelectedValue & "', '" &...
4
by: CJ Taylor | last post by:
Alright, I wrote this program that is used throughout my entire company for the past 9 months. Now, we have deployed it to well over 100 machines. So my Sys Admin comes up to me today and...
1
by: Marco | last post by:
I'm having some a really weird issue with datagrids. Basically they work fine until you update the data while a cell is selected. If you do that then the old selected cell will remain on the...
0
by: berry | last post by:
Hi... I very need yours help. I having a very weird problem. I want to consider the datagrid is empty or not, then if not empty, i want to total up the value. I using datagrid.text <> "" in my code....
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.