-
ASP.NET (
http://www.daniweb.com/forums/forum18.html)
| smd5049 | Nov 6th, 2009 11:37 am | |
| datagrid return value - please help 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 |
| adatapost | Nov 7th, 2009 8:39 am | |
| |
| Sals | Nov 9th, 2009 1:14 am | |
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
Quote: Originally Posted by smd5049 (Post 1039193) 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 | |
| smd5049 | Nov 9th, 2009 3:40 pm | |
I am able to return all the values of the datagrid except the last column (item.cells(6).text). The vb looks like this For Each item In DataGrid1.Items
Label1.Text &= "<br />" & item.Cells(0).Text & _
" " & item.Cells(1).Text & _
" " & item.Cells(2).Text & _
" " & item.Cells(3).Text & _
" " & item.Cells(4).Text & _
" " & item.Cells(5).Text & _
" " & item.Cells(6).Text
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:DataGrid ID="DataGrid1" runat="server" AutoGenerateColumns="False" BackColor="White"
BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Horizontal">
<SelectedItemStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left" />
<FooterStyle BackColor="#CCCC99" ForeColor="Black" />
<Columns>
<asp:BoundColumn DataField="Order_Line" HeaderText="Line"></asp:BoundColumn>
<asp:BoundColumn DataField="TN_CN_S_Desc" HeaderText="Description">
<ItemStyle HorizontalAlign="Left" />
</asp:BoundColumn>
<asp:BoundColumn DataField="Item" HeaderText="Item"></asp:BoundColumn>
<asp:BoundColumn DataField="Pack" HeaderText="Pack"></asp:BoundColumn>
<asp:BoundColumn DataField="Location" HeaderText="Location"></asp:BoundColumn>
<asp:BoundColumn DataField="Lot" HeaderText="Lot"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="# Labels">
<ItemTemplate>
<asp:TextBox runat="server" Style="text-align: right" Text='<%# DataBinder.Eval(Container.DataItem,"Label_Nb") %>'
Width="65"></asp:TextBox>
</ItemTemplate>
<HeaderStyle Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
Font-Underline="False" HorizontalAlign="Right" />
<ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
Font-Underline="False" HorizontalAlign="Right" />
</asp:TemplateColumn>
</Columns>
<PagerStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
Font-Underline="False" HorizontalAlign="Left" />
</asp:DataGrid>
how am i to display the values from this template column? |
| All times are GMT -4. The time now is 12:54 am. | |
Forum system based on vBulletin Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
©2003 - 2010 DaniWeb® LLC