datagrid return value - please help

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2009
Posts: 9
Reputation: smd5049 is an unknown quantity at this point 
Solved Threads: 0
smd5049 smd5049 is offline Offline
Newbie Poster

datagrid return value - please help

 
0
  #1
17 Days Ago
will someone please help me with this. It seems simple enough but I'm very new to asp and vb. I have a datagrid and I want to know how to access the values in a specific column. The dg is bound to a sql query. The column returns integer values in sql. I want to be able to sum the column and have a button_click command send the datagrid values to 0. I only want to change the datagrid values NOT the sql values (I currently have an Update/Set sql command in vb for this but as I said I only want the Datagrid values to change). Simply put where, if anywhere are the datagrid values stored? I have the column set as a template column and the items are displayed in the datagrid as textboxes (to allow the cells in this column to be changed). can someone please help or at least tell me if this question makes any sense. thank you
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,559
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 454
Moderator
adatapost's Avatar
adatapost adatapost is online now Online
Posting Maven
 
1
  #2
16 Days Ago
Show us your code work please. You will find some useful information from this MSDN page - http://msdn.microsoft.com/en-us/library/aa479339.aspx
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 11
Reputation: Sals is an unknown quantity at this point 
Solved Threads: 1
Sals Sals is offline Offline
Newbie Poster
 
0
  #3
15 Days Ago
You can access a perticular colum in dataset by
ds.Tables[0].Rows[0]["Columnname"].ToString()

You can access a particular column of gridview in its Rowdatabound event

Hope one of it may help u


Originally Posted by smd5049 View Post
will someone please help me with this. It seems simple enough but I'm very new to asp and vb. I have a datagrid and I want to know how to access the values in a specific column. The dg is bound to a sql query. The column returns integer values in sql. I want to be able to sum the column and have a button_click command send the datagrid values to 0. I only want to change the datagrid values NOT the sql values (I currently have an Update/Set sql command in vb for this but as I said I only want the Datagrid values to change). Simply put where, if anywhere are the datagrid values stored? I have the column set as a template column and the items are displayed in the datagrid as textboxes (to allow the cells in this column to be changed). can someone please help or at least tell me if this question makes any sense. thank you
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 9
Reputation: smd5049 is an unknown quantity at this point 
Solved Threads: 0
smd5049 smd5049 is offline Offline
Newbie Poster
 
0
  #4
14 Days Ago
I am able to return all the values of the datagrid except the last column (item.cells(6).text). The vb looks like this
  1. For Each item In DataGrid1.Items
  2. Label1.Text &= "<br />" & item.Cells(0).Text & _
  3. " " & item.Cells(1).Text & _
  4. " " & item.Cells(2).Text & _
  5. " " & item.Cells(3).Text & _
  6. " " & item.Cells(4).Text & _
  7. " " & item.Cells(5).Text & _
  8. " " & item.Cells(6).Text
  9.  
  10. Next item

The difference with this column in the asp is that the values returned from the sql query are placed into editable text boxes. the asp for the datagrid is here
  1. <asp:DataGrid ID="DataGrid1" runat="server" AutoGenerateColumns="False" BackColor="White"
  2. BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Horizontal">
  3. <SelectedItemStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
  4. <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left" />
  5. <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
  6. <Columns>
  7. <asp:BoundColumn DataField="Order_Line" HeaderText="Line"></asp:BoundColumn>
  8. <asp:BoundColumn DataField="TN_CN_S_Desc" HeaderText="Description">
  9. <ItemStyle HorizontalAlign="Left" />
  10. </asp:BoundColumn>
  11. <asp:BoundColumn DataField="Item" HeaderText="Item"></asp:BoundColumn>
  12. <asp:BoundColumn DataField="Pack" HeaderText="Pack"></asp:BoundColumn>
  13. <asp:BoundColumn DataField="Location" HeaderText="Location"></asp:BoundColumn>
  14. <asp:BoundColumn DataField="Lot" HeaderText="Lot"></asp:BoundColumn>
  15. <asp:TemplateColumn HeaderText="# Labels">
  16.  
  17. <ItemTemplate>
  18. <asp:TextBox runat="server" Style="text-align: right" Text='<%# DataBinder.Eval(Container.DataItem,"Label_Nb") %>'
  19. Width="65"></asp:TextBox>
  20. </ItemTemplate>
  21. <HeaderStyle Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
  22. Font-Underline="False" HorizontalAlign="Right" />
  23. <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
  24. Font-Underline="False" HorizontalAlign="Right" />
  25. </asp:TemplateColumn>
  26.  
  27. </Columns>
  28. <PagerStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
  29. Font-Underline="False" HorizontalAlign="Left" />
  30. </asp:DataGrid>

how am i to display the values from this template column?
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC