This message was discovered on ASPFriends.com 'aspngdatagridrepeaterdatalist' list.
| Paul Matthews |
Hi All
I have a shopping cart which I am displaying using a datagrid. This shoppingcart has as the name of the product, the id of the product, the quantity of the product and also an update button. This update button allows the user to change the quantity. My Question is how to I retrieve the value in the quantity field. I can retrieve the product id using the Datakeys property however cannot seem to get the quanity.
Many Thanks in advance
Paul.
My code for the datagrid is below.
<asp:datagrid id="DGridBasket" runat="server" Height="163px" Width="554px" AutoGenerateColumns="false" DataKeyField="Productid" ItemStyle-CssClass="CartListItem" FooterStyle-CssClass="CartListFooter" HeaderStyle-CssClass="CartListHead" Font-Size="8pt" Font-Name="Verdana" GridLines="Vertical" BorderColor="black" OnItemCommand="dGridBasket_ItemCommand">
<AlternatingItemStyle BorderStyle="Solid" CssClass="CartListItemAlt"></AlternatingItemStyle> <ItemStyle CssClass="CartListItem"></ItemStyle> <HeaderStyle CssClass="CartListHead"></HeaderStyle> <FooterStyle CssClass="CartListFooter"></FooterStyle>
<Columns> <asp:BoundColumn DataField="ProductID" HeaderText="Product Code"></asp:BoundColumn> <asp:BoundColumn DataField="Title" HeaderText="Description"></asp:BoundColumn> <asp:TemplateColumn HeaderText="Quantity"> <ItemTemplate> <asp:TextBox id="Quantity" runat="server" Columns="4" MaxLength="3" Text='<%# DataBinder.Eval(Container.DataItem, "Quantity") %>' width="40px" /> </ItemTemplate> </asp:TemplateColumn> <asp:BoundColumn dataField="unitcost" HeaderText="Unit Cost"></asp:BoundColumn> <asp:TemplateColumn HeaderText="Remove"> <ItemTemplate> <center> <asp:CheckBox id="Remove" runat="server" /> </center> </ItemTemplate> </asp:TemplateColumn> <asp:ButtonColumn CommandName="Update" Text="Update" />
</Columns> </asp:datagrid>
|
|
| |
| |
| Dean Santillan |
I have the same problem, I have read quite a few documents and from what i have read when it comes to retreiving values from a bound column you use the following code.
TextBox txtQuantity = (TextBox)e.Item.Cell[index].Controls[0] Label lblQuantity = (TextBox)e.Item.Cell[index].Controls[0]
or for templated columns
TextBox txtQuantity = (TextBox)e.Item.FindControl("txtQuantity")
then you use txtQuantity.Text to get the value;
This is what I have read but I cant seem to get the correct values out as well. When I look at the forms collection in the page trace output the values are correct. But they are not they values I have received or the updated values. I can receve the datakeys property as well but not anything else.
Dean
-----Original Message----- From: Paul Matthews [mailto:Click here to reveal e-mail address] Sent: Thursday, August 08, 2002 8:43 PM To: aspngDataGridRepeaterDatalist Subject: [aspngdatagridrepeaterdatalist] retrieving values
Hi All
I have a shopping cart which I am displaying using a datagrid. This shoppingcart has as the name of the product, the id of the product, the quantity of the product and also an update button. This update button allows the user to change the quantity. My Question is how to I retrieve the value in the quantity field. I can retrieve the product id using the Datakeys property however cannot seem to get the quanity.
Many Thanks in advance
Paul.
My code for the datagrid is below.
<asp:datagrid id="DGridBasket" runat="server" Height="163px" Width="554px" AutoGenerateColumns="false" DataKeyField="Productid" ItemStyle-CssClass="CartListItem" FooterStyle-CssClass="CartListFooter" HeaderStyle-CssClass="CartListHead" Font-Size="8pt" Font-Name="Verdana" GridLines="Vertical" BorderColor="black" OnItemCommand="dGridBasket_ItemCommand">
<AlternatingItemStyle BorderStyle="Solid" CssClass="CartListItemAlt"></AlternatingItemStyle> <ItemStyle CssClass="CartListItem"></ItemStyle> <HeaderStyle CssClass="CartListHead"></HeaderStyle> <FooterStyle CssClass="CartListFooter"></FooterStyle>
<Columns> <asp:BoundColumn DataField="ProductID" HeaderText="Product Code"></asp:BoundColumn> <asp:BoundColumn DataField="Title" HeaderText="Description"></asp:BoundColumn> <asp:TemplateColumn HeaderText="Quantity"> <ItemTemplate> <asp:TextBox id="Quantity" runat="server" Columns="4" MaxLength="3" Text='<%# DataBinder.Eval(Container.DataItem, "Quantity") %>' width="40px" /> </ItemTemplate> </asp:TemplateColumn> <asp:BoundColumn dataField="unitcost" HeaderText="Unit Cost"></asp:BoundColumn> <asp:TemplateColumn HeaderText="Remove"> <ItemTemplate> <center> <asp:CheckBox id="Remove" runat="server" /> </center> </ItemTemplate> </asp:TemplateColumn> <asp:ButtonColumn CommandName="Update" Text="Update" />
</Columns> </asp:datagrid>
| [aspngdatagridrepeaterdatalist] member Click here to reveal e-mail address = YOUR ID | http://www.aspfriends.com/aspfriends/aspngdatagridrepeaterdatalist.asp = JOIN/QUIT
|
|
| |
|
| |
| Paul Matthews |
has anyone got any examples of this. i.e retrieving multiple columns from a datagrid
many thanks Paul
-----Original Message----- From: Dean Santillan [mailto:Click here to reveal e-mail address] Sent: 08 August 2002 13:24 To: aspngDataGridRepeaterDatalist Subject: [aspngdatagridrepeaterdatalist] RE: retrieving values
I have the same problem, I have read quite a few documents and from what i have read when it comes to retreiving values from a bound column you use the following code.
TextBox txtQuantity = (TextBox)e.Item.Cell[index].Controls[0] Label lblQuantity = (TextBox)e.Item.Cell[index].Controls[0]
or for templated columns
TextBox txtQuantity = (TextBox)e.Item.FindControl("txtQuantity")
then you use txtQuantity.Text to get the value;
This is what I have read but I cant seem to get the correct values out as well. When I look at the forms collection in the page trace output the values are correct. But they are not they values I have received or the updated values. I can receve the datakeys property as well but not anything else.
Dean
-----Original Message----- From: Paul Matthews [mailto:Click here to reveal e-mail address] Sent: Thursday, August 08, 2002 8:43 PM To: aspngDataGridRepeaterDatalist Subject: [aspngdatagridrepeaterdatalist] retrieving values
Hi All
I have a shopping cart which I am displaying using a datagrid. This shoppingcart has as the name of the product, the id of the product, the quantity of the product and also an update button. This update button allows the user to change the quantity. My Question is how to I retrieve the value in the quantity field. I can retrieve the product id using the Datakeys property however cannot seem to get the quanity.
Many Thanks in advance
Paul.
My code for the datagrid is below.
<asp:datagrid id="DGridBasket" runat="server" Height="163px" Width="554px" AutoGenerateColumns="false" DataKeyField="Productid" ItemStyle-CssClass="CartListItem" FooterStyle-CssClass="CartListFooter" HeaderStyle-CssClass="CartListHead" Font-Size="8pt" Font-Name="Verdana" GridLines="Vertical" BorderColor="black" OnItemCommand="dGridBasket_ItemCommand">
<AlternatingItemStyle BorderStyle="Solid" CssClass="CartListItemAlt"></AlternatingItemStyle> <ItemStyle CssClass="CartListItem"></ItemStyle> <HeaderStyle CssClass="CartListHead"></HeaderStyle> <FooterStyle CssClass="CartListFooter"></FooterStyle>
<Columns> <asp:BoundColumn DataField="ProductID" HeaderText="Product Code"></asp:BoundColumn> <asp:BoundColumn DataField="Title" HeaderText="Description"></asp:BoundColumn> <asp:TemplateColumn HeaderText="Quantity"> <ItemTemplate> <asp:TextBox id="Quantity" runat="server" Columns="4" MaxLength="3" Text='<%# DataBinder.Eval(Container.DataItem, "Quantity") %>' width="40px" /> </ItemTemplate> </asp:TemplateColumn> <asp:BoundColumn dataField="unitcost" HeaderText="Unit Cost"></asp:BoundColumn> <asp:TemplateColumn HeaderText="Remove"> <ItemTemplate> <center> <asp:CheckBox id="Remove" runat="server" /> </center> </ItemTemplate> </asp:TemplateColumn> <asp:ButtonColumn CommandName="Update" Text="Update" />
</Columns> </asp:datagrid>
| [aspngdatagridrepeaterdatalist] member Click here to reveal e-mail address = YOUR ID | http://www.aspfriends.com/aspfriends/aspngdatagridrepeaterdatalist.asp = JOIN/QUIT
| [aspngdatagridrepeaterdatalist] member Click here to reveal e-mail address = YOUR ID | http://www.aspfriends.com/aspfriends/aspngdatagridrepeaterdatalist.asp = JOIN/QUIT
|
|
| |
|
| |
| Anthony Merante |
Hi Paul.
Dim Qty As String = CType(e.Item.FindControl( _
"txtQty"), TextBox).Text
just make sure you name your Textbox txtQty
HTH,
Anthony
"Paul Matthews" <Click here to reveal e-mail address> wrote in message news:695265@aspngdatagridrepeaterdatalist... [Original message clipped]
|
|
| |
|
| | |
| |
| Mohammed Mudassir |
I guess, you can visit the site that is ASP.NET or ASPAlliance.com I saw that Article, but not remember exact URL of that article.
Take Care,
Mudassir ----- Original Message ----- From: "Paul Matthews" <Click here to reveal e-mail address> To: "aspngDataGridRepeaterDatalist" <Click here to reveal e-mail address> Sent: Friday, August 09, 2002 1:20 PM Subject: [aspngdatagridrepeaterdatalist] RE: retrieving values
> has anyone got any examples of this. i.e retrieving multiple columns from a [Original message clipped]
|
|
| |
|
|
|
|
|