Hi Guys,
I have been stuck on this problem for several days now, i have a set of
nested datagrids. Inside the second datagrid i have a dropdown list, a
textbox and a label. I want the textbox to update the label with the value
of the dropdown list * the text box quantity. I am using an onTextChaged
even on the textbox, the problem i have is that i can not find the lblPrice
control.
Thanks for the help,
Josh
INLINE CODE:
<asp:datagrid id="dgCategories" runat="server" AutoGenerateColumns="False"
VerticalAlign="Top"
HorizontalAlign="Center" border="0" Font-Names="Verdana"
CellPadding="4" ItemStyle-CssClass="p"
headerStyle-CssClass="p" Width="95%">
<ItemStyle CssClass="tabletext"></ItemStyle>
<HeaderStyle CssClass="header"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="styleName"
HeaderText="Category"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="">
<ItemTemplate>
<asp:DataGrid id="dgProducts" ShowHeader=False runat="server"
AutoGenerateColumns="False" DataSource='<%# GetProducts
(container.dataitem("catID"))%>' Width="100%" headerStyle-CssClass="p"
ItemStyle-CssClass="p" BorderWidth=0 OnCancelCommand="dgProducts_Cancel"
OnUpdateCommand="dgProducts_Update" OnEditCommand="dgProducts_Edit"
OnItemDataBound="dgProducts_DataBound" DataKeyField="styleID">
<ItemStyle CssClass="tabletextinner"></ItemStyle>
<Columns>
<asp:BoundColumn DataField="styleID" HeaderText="Name"
Visible="false"></asp:BoundColumn>
<asp:BoundColumn DataField="styleName" HeaderText="Name"
Visible="false"></asp:BoundColumn>
<asp:TemplateColumn>
<ItemTemplate>
Style:
<asp:DropDownList id="ddlSize"
runat="server"></asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
Quantity:
<asp:TextBox id="txtQuantity" runat="server" AutoPostBack=true
OnTextChanged="txtQuantity_TextChanged" Width="70"></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
Price:
<asp:Label id="lblPrice" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
CODE BEHIND
Function GetProducts(ByVal x As String)
Dim params As String() = {"@catID", x}
Dim dsClients As DataSet = database.SPFill("sp_getProductsInCat", "clients",
params)
Response.Write("catID = " & x)
Return dsClients.Tables(0)
End Function
Sub txtQuantity_TextChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim price As System.Web.UI.WebControls.Label
' Find control on page.
Dim i As Integer = 0
While i < 20
Try
price = CType(dgProducts.Items(i).Cells(4).FindControl("lb lPrice"),
System.Web.UI.WebControls.Label)
price.Text = "MOFO"
Catch ex As Exception
End Try
i = i + 1
End While
End Sub
Sub dgProducts_DataBound(ByVal obj As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs)
Dim size As System.Web.UI.WebControls.DropDownList
Dim shape As System.Web.UI.WebControls.DropDownList
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.EditItem Then
size = CType(e.Item.Cells(2).Controls(1),
System.Web.UI.WebControls.DropDownList)
'set the drop down lists witht eh apprioprtite infomation
Dim params As String() = {"@styleID", e.Item.Cells(0).Text}
Dim dsSizesShapes As DataSet = database.SPFill("sp_getProductsForStyle",
"tbl_products", params)
Dim dr As DataRow
For Each dr In dsSizesShapes.Tables(0).Rows
size.Items.Add(New ListItem(convertToWeight(dr("productSize")) & " \ " &
dr("productShape"), dr("productPrice")))
Next
End If
End Sub 2 3144
did you try?
price = CType(dgProducts.Items(i).FindControl("lblPrice"),
System.Web.UI.WebControls.Label)
[Find the control in the Row (assuming you have a uniquely named control -
which it appears to be so) ...]
"Josh" <jo**@rb.com.auREMOVETOEMAIL> wrote in message
news:un**************@TK2MSFTNGP11.phx.gbl... Hi Guys,
I have been stuck on this problem for several days now, i have a set of nested datagrids. Inside the second datagrid i have a dropdown list, a textbox and a label. I want the textbox to update the label with the value of the dropdown list * the text box quantity. I am using an onTextChaged even on the textbox, the problem i have is that i can not find the lblPrice control.
Thanks for the help, Josh
INLINE CODE: <asp:datagrid id="dgCategories" runat="server" AutoGenerateColumns="False" VerticalAlign="Top" HorizontalAlign="Center" border="0" Font-Names="Verdana" CellPadding="4" ItemStyle-CssClass="p" headerStyle-CssClass="p" Width="95%"> <ItemStyle CssClass="tabletext"></ItemStyle> <HeaderStyle CssClass="header"></HeaderStyle> <Columns> <asp:BoundColumn DataField="styleName" HeaderText="Category"></asp:BoundColumn> <asp:TemplateColumn HeaderText=""> <ItemTemplate> <asp:DataGrid id="dgProducts" ShowHeader=False runat="server" AutoGenerateColumns="False" DataSource='<%# GetProducts (container.dataitem("catID"))%>' Width="100%" headerStyle-CssClass="p" ItemStyle-CssClass="p" BorderWidth=0 OnCancelCommand="dgProducts_Cancel" OnUpdateCommand="dgProducts_Update" OnEditCommand="dgProducts_Edit" OnItemDataBound="dgProducts_DataBound" DataKeyField="styleID"> <ItemStyle CssClass="tabletextinner"></ItemStyle> <Columns> <asp:BoundColumn DataField="styleID" HeaderText="Name" Visible="false"></asp:BoundColumn> <asp:BoundColumn DataField="styleName" HeaderText="Name" Visible="false"></asp:BoundColumn> <asp:TemplateColumn> <ItemTemplate> Style: <asp:DropDownList id="ddlSize" runat="server"></asp:DropDownList> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn> <ItemTemplate> Quantity: <asp:TextBox id="txtQuantity" runat="server" AutoPostBack=true OnTextChanged="txtQuantity_TextChanged" Width="70"></asp:TextBox> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn> <ItemTemplate> Price: <asp:Label id="lblPrice" runat="server"></asp:Label> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:datagrid>
CODE BEHIND Function GetProducts(ByVal x As String) Dim params As String() = {"@catID", x}
Dim dsClients As DataSet = database.SPFill("sp_getProductsInCat", "clients", params)
Response.Write("catID = " & x)
Return dsClients.Tables(0)
End Function Sub txtQuantity_TextChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim price As System.Web.UI.WebControls.Label
' Find control on page.
Dim i As Integer = 0
While i < 20
Try
price = CType(dgProducts.Items(i).Cells(4).FindControl("lb lPrice"), System.Web.UI.WebControls.Label)
price.Text = "MOFO"
Catch ex As Exception
End Try
i = i + 1
End While
End Sub Sub dgProducts_DataBound(ByVal obj As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
Dim size As System.Web.UI.WebControls.DropDownList
Dim shape As System.Web.UI.WebControls.DropDownList
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.EditItem Then
size = CType(e.Item.Cells(2).Controls(1), System.Web.UI.WebControls.DropDownList)
'set the drop down lists witht eh apprioprtite infomation
Dim params As String() = {"@styleID", e.Item.Cells(0).Text}
Dim dsSizesShapes As DataSet = database.SPFill("sp_getProductsForStyle", "tbl_products", params)
Dim dr As DataRow
For Each dr In dsSizesShapes.Tables(0).Rows
size.Items.Add(New ListItem(convertToWeight(dr("productSize")) & " \ " & dr("productShape"), dr("productPrice")))
Next
End If
End Sub
Hi Josh:
this article has C# code but it gives some more insight into using
FindControl: http://odetocode.com/Articles/116.aspx
--
Scott http://www.OdeToCode.com
On Tue, 31 Aug 2004 13:38:51 +1000, "Josh"
<jo**@rb.com.auREMOVETOEMAIL> wrote: Hi Guys,
I have been stuck on this problem for several days now, i have a set of nested datagrids. Inside the second datagrid i have a dropdown list, a textbox and a label. I want the textbox to update the label with the value of the dropdown list * the text box quantity. I am using an onTextChaged even on the textbox, the problem i have is that i can not find the lblPrice control. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: DelphiBlue |
last post by:
I have a Nested Datagrid that is using a data relations to tie the parent
child datagrids together. All is working well with the display but I am
having some issues trying to sort the child...
|
by: Das |
last post by:
Hi,
I have made an application in ASP.net with C#. The application works fine with localhost. I have uploaded the site.
I'm using web user controls in the form. but some of the button do not work...
|
by: bill yeager |
last post by:
I have a datagrid control within a datalist control. When
I try and do a "Find" on the control, the object comes
back with nothing and then my pgm crashes. I am 100% sure
that my datagird inside...
|
by: Nevyn Twyll |
last post by:
I have a multi-level datalist setup:
DataList1
DataList2
MyGrid
I have columns explicitly defined for the grid in the html.
Sometimes, On the initial Load() of the Page, I want to add extra...
|
by: tshad |
last post by:
How do I find (and set) a couple of labels in the Footer after a DataGrid is
filled?
I have a bunch of DataGrids that get displayed nested inside a DataList.
The datagrid looks like:
...
|
by: Roy |
last post by:
How is it done? BTW, I'm reposting this here, as the datagrid newsgroup
appears functionally comatose...
I have a nested datagrid setup. When one updates the child grid using
edit, it also...
|
by: I am Sam |
last post by:
Ok whats wrong with my toolbar? When I debug I don't get an error message
and the databinding is working correctly but the toolbar itself and the
<iewc:ToolbarDropDownlist /> control isn't showing...
|
by: nulldevice |
last post by:
I've got a datagrid with some nested controls, created at design-time. The
controls themselves have no databound values.
After a few other operations on the page (selecting a few parameters,...
|
by: sck10 |
last post by:
Hello,
I am using the code below to set the values of a DetailsView template field
using FindControl. My question is how would you find a control if its a
Boundfield control?
For example,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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,...
| |