473,324 Members | 2,257 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Fixed the problem

CW
I didn't have
If !Page.IsPostBack
//bind data source

in the code

"CW" <a> wrote in message news:um**************@TK2MSFTNGP12.phx.gbl...
I am taking the Commerce Starter Kit sample from asp.net and trying to add a page that allows user to edit product categories.

I am doing so via the use of a datagrid. html portion related to the data
grid is as per follows:

<asp:datagrid id=dgProductCategories runat="server"
AutoGenerateColumns="False" DataSource="<%# DataSet11 %>" Width="275px"
BorderColor="#999999" BorderStyle="None" BackColor="White" CellPadding="3"
GridLines="Vertical" BorderWidth="1px" DataKeyField="CategoryID"
DataMember="CMRC_Categories">
<SelectedItemStyle Font-Bold="True" ForeColor="White"
BackColor="#008A8C"></SelectedItemStyle>
<AlternatingItemStyle
BackColor="Gainsboro"></AlternatingItemStyle>
<ItemStyle ForeColor="Black" BackColor="#EEEEEE"></ItemStyle> <HeaderStyle Font-Bold="True" ForeColor="White"
BackColor="#000084"></HeaderStyle>
<FooterStyle ForeColor="Black"
BackColor="#CCCCCC"></FooterStyle>
<Columns>
<asp:BoundColumn DataField="CategoryID"
SortExpression="CategoryID" ReadOnly="True"
HeaderText="ID"></asp:BoundColumn>
<asp:BoundColumn DataField="CategoryName"
SortExpression="CategoryName" HeaderText="Category Name"></asp:BoundColumn> <asp:EditCommandColumn ButtonType="LinkButton"
UpdateText="Update" HeaderText="Edit" CancelText="Cancel"
EditText="Edit"></asp:EditCommandColumn>
<asp:ButtonColumn Text="Delete" HeaderText="Delete"
CommandName="Delete"></asp:ButtonColumn>
</Columns>
<PagerStyle HorizontalAlign="Center" ForeColor="Black"
BackColor="#999999" Mode="NumericPages"></PagerStyle>
</asp:datagrid>

The code behind that handles the Update command is as per follows:

Private Sub dgProductCategories_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
dgProductCategories.UpdateCommand
Dim dr As DataSet1.CMRC_CategoriesRow
dr =
Me.DataSet11.CMRC_Categories.FindByCategoryID(CInt (Me.dgProductCategories.It ems(e.Item.ItemIndex).Cells(0).Text))
Dim tbProductCategory As System.Web.UI.WebControls.TextBox =
CType(e.Item.Cells(1).Controls(0), System.Web.UI.WebControls.TextBox)
dr.Item(1) = tbProductCategory.Text
Me.SqlDataAdapter1.Update(Me.DataSet11)
Me.dgProductCategories.EditItemIndex = -1
Me.dgProductCategories.DataBind()
End Sub

e.Item.Cells(1).Controls(0) supposed to the be the textbox when datagrid is in edit mode. However, in debug mode, I could tell that the value in the
text box is the original value, rather than the edited value. Of course this means that the edit operation would have no effect.

I also tried using
Me.dgProductCategories.Items(e.Item.ItemIndex).Cel ls(1).Controls(0) instead of e.Item.Cells(1).Controls(0) in the code. However, it made no difference.
Any idea what's happening there?

Thanks in advance

CW

Nov 18 '05 #1
0 689

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

Similar topics

179
by: SoloCDM | last post by:
How do I keep my entire web page at a fixed width? ********************************************************************* Signed, SoloCDM
9
by: pout | last post by:
What are the purposes of fixed-point? When should it be used? I read: #define Int2Fixed(x) (((long)(short)x) << 16) and the fixed-point in 16.16 format. Does the 16 in the MACRO refer to...
9
by: pout | last post by:
What are the purposes of fixed-point? When should it be used? I read: #define Int2Fixed(x) (((long)(short)x) << 16) and the fixed-point in 16.16 format. Does the 16 in the MACRO refer to...
4
by: Otie | last post by:
Hello, I am using the MSFlexGrd Control in VB5. I have 1 fixed row and one fixed column. I am trying to do a sort when the user clicks a column in the FIXED ROW. But when I capture the row...
1
by: tehweb | last post by:
Background: I have a fixed position div on the bottom om my page. I have then added a dialog-div into this fixed position one. When I bring up the dialog, everything works if the the scrollTop is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.