943,993 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 860
  • ASP.NET RSS
Nov 6th, 2009
0

datagrid return value - please help

Expand 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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
smd5049 is offline Offline
10 posts
since Nov 2009
Nov 7th, 2009
1
Re: datagrid return value - please help
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
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
Nov 9th, 2009
0
Re: datagrid return value - please help
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


Click to Expand / Collapse  Quote originally posted by smd5049 ...
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
Reputation Points: 10
Solved Threads: 6
Light Poster
Sals is offline Offline
33 posts
since Jan 2009
Nov 9th, 2009
0
Re: datagrid return value - please help
I am able to return all the values of the datagrid except the last column (item.cells(6).text). The vb looks like this
ASP.NET Syntax (Toggle Plain Text)
  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
ASP.NET Syntax (Toggle Plain Text)
  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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
smd5049 is offline Offline
10 posts
since Nov 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Web form like window classic form
Next Thread in ASP.NET Forum Timeline: Editing Registry Keys





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC