473,685 Members | 3,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid Cells: Getting the value

We have a datagrid built using template columns. Many are
text boxes. These text boxes are bound to a datasource as
follows: <ItemTemplate >
<asp:TextBox
id="txtPeriod1 "
runat="server"
columns="1"
Font-Size="8pt"
text='<%# Container.datai tem
("LaborHoursAm" )%>' >
</asp:TextBox>
</ItemTemplate>

My problem arises when I change the data (like changing
txtPeriod1 from 80 to 30) in the column and try to
retrieve it. When I spin through the datagrid values I see
the "80", the bound value, not the "30" the value I want
to change it too. Is there a way I can accomplish this?
Nov 18 '05 #1
3 1668
If you are using a DataSet - - you need to first, update the dataset before
you 'spin through' the datagrid (I assume you mean Dataset - - otherwise - -
show us how you're doing it)
David Wier
MCP, MVP ASP.NET, ASPInsider
http://aspnet101.com
http://aspexpress.com
"ALPO" <an*******@disc ussions.microso ft.com> wrote in message
news:06******** *************** *****@phx.gbl.. .
We have a datagrid built using template columns. Many are
text boxes. These text boxes are bound to a datasource as
follows: <ItemTemplate >
<asp:TextBox
id="txtPeriod1 "
runat="server"
columns="1"
Font-Size="8pt"
text='<%# Container.datai tem
("LaborHoursAm" )%>' >
</asp:TextBox>
</ItemTemplate>

My problem arises when I change the data (like changing
txtPeriod1 from 80 to 30) in the column and try to
retrieve it. When I spin through the datagrid values I see
the "80", the bound value, not the "30" the value I want
to change it too. Is there a way I can accomplish this?

Nov 18 '05 #2
Yes it is a dataset. However, how can i update the
dataset with the new value? The tricky part is we are
trying to avoid the single row edits so we don't have
an "editcommandbut ton". Our thought was to spin through
the items in the datagrid page, update the dataset, then
bind the grid again. Here is what i am trying to do in
the code behind.

For iItemCount = 0 To LaborGrid.Items .Count - 1
LaborGrid.Selec tedIndex = iItemCount
Debug.Write(Lab orGrid.Selected Index & vbCrLf)
With LaborGrid.Selec tedItem
Debug.Write("se lecteditem :" &
LaborGrid.Selec tedItem.Cells(8 ).Text & vbCrLf)
txtbox = LaborGrid.Selec tedItem.FindCon trol
("txtPeriod1 ")
'value = txtbox.Text
'Debug.Write("v alue :" & value & vbCrLf)
End With
Next

I get my selecteditem number ok, but I can't get the new
number. I am missing something here, something that
the "editcommandbut ton" would do. We are using a non-grid
button because the user wants to be able to update any
column of any row before updating. Is it possible?
-----Original Message-----
If you are using a DataSet - - you need to first, update the dataset beforeyou 'spin through' the datagrid (I assume you mean Dataset - - otherwise - -show us how you're doing it)
David Wier
MCP, MVP ASP.NET, ASPInsider
http://aspnet101.com
http://aspexpress.com
"ALPO" <an*******@disc ussions.microso ft.com> wrote in messagenews:06******* *************** ******@phx.gbl. ..
We have a datagrid built using template columns. Many are text boxes. These text boxes are bound to a datasource as follows: <ItemTemplate >
<asp:TextBox
id="txtPeriod1 "
runat="server"
columns="1"
Font-Size="8pt"
text='<%# Container.datai tem
("LaborHoursAm" )%>' >
</asp:TextBox>
</ItemTemplate>

My problem arises when I change the data (like changing
txtPeriod1 from 80 to 30) in the column and try to
retrieve it. When I spin through the datagrid values I see the "80", the bound value, not the "30" the value I want
to change it too. Is there a way I can accomplish this?

.

Nov 18 '05 #3
This is basically what i want to do......

1) The user changes values for a few columns in different
rows
2)The user clicks a "recalc" button
3)The new values of the cells in are updated into the
cached dataset
4)Perform a DataBind

Sorry if I am confusing you, I've just been trying to skin
this cat for a couple of days, and I am furstrated and
beginning to think it can't be done.
-----Original Message-----
If you are using a DataSet - - you need to first, update the dataset beforeyou 'spin through' the datagrid (I assume you mean Dataset - - otherwise - -show us how you're doing it)
David Wier
MCP, MVP ASP.NET, ASPInsider
http://aspnet101.com
http://aspexpress.com
"ALPO" <an*******@disc ussions.microso ft.com> wrote in messagenews:06******* *************** ******@phx.gbl. ..
We have a datagrid built using template columns. Many are text boxes. These text boxes are bound to a datasource as follows: <ItemTemplate >
<asp:TextBox
id="txtPeriod1 "
runat="server"
columns="1"
Font-Size="8pt"
text='<%# Container.datai tem
("LaborHoursAm" )%>' >
</asp:TextBox>
</ItemTemplate>

My problem arises when I change the data (like changing
txtPeriod1 from 80 to 30) in the column and try to
retrieve it. When I spin through the datagrid values I see the "80", the bound value, not the "30" the value I want
to change it too. Is there a way I can accomplish this?

.

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3478
by: kscdavefl | last post by:
I ahve a datagrid on a web form. I need to change the value in column 3 as follows. If the value in column 3 reads 0, I want to change it to read YES. How can I accomplish this task. Thanks, Dave
2
2213
by: Joe Au | last post by:
I follow the Walkthrough documented on Visual Studio to create an editable data grid but it does not work on getting the value of the textbox in the data grid. The code is copied here. I mark "*****" at which the categoryName always get the past value no matter what it has been changed. How do I fix it? Thanks. Joe. Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As...
5
3525
by: Lie | last post by:
Hi all, I have problem in getting selectedindex of multiple listbox selection in a datagrid. I have a listbox with multiple selection mode inside datagrid. In Edit mode, I need to get back all selected items of that listbox and display it. can anyone help? Thanks
13
2646
by: Lyners | last post by:
I have a web page writen in ASP.NET that contains some javascript so that when a user presses a button, or edits a certain field in a datagrid, another cell in the datagrid is filled with a value. My probelm.... when I have the user press the update button (which does a post back that loops through the datagrid and updates a database) the field/cell that is filled by the javascript appears to be blank in my update code, even though I can...
2
2067
by: Gummy | last post by:
Hello All, I have a webpage that has two dropdown listboxes. Based on what is selected in these dropdown listboxes, it filters a DataGrid . That works fine. In the DataGrid , when I go to edit a row, I change the textbox (or other control), click Update, but it doesn't save my data. I then did this... In Page_Load, I added code to filter the DataGrid only when it was Not Page.IsPostBack. Then the editing/updating of the DataGrid data...
6
5739
by: p.mc | last post by:
Hi all, I'm having major problems with a userControl which contains a datagrid. My problem concerns data binding. The Page_Load() procedure calls the DataBind procedure to bind the datagrid to a DataSet. If i include an if statement to prevent the data binding from occuring on a page PostBack in the following way:
5
3151
by: Antonio | last post by:
Hello, everyone. Is there a way to not display a certain value in a datagrid cell? I have a datagrid for subscriptions and ebooks and if there isn't an e-book listed, the value from the database (SQL) is "Null/No Set Dummy Row". Is there a way I can suppress that data in the datagrid? Thanks,
1
2591
by: sp | last post by:
Hello I have a problem with the refresh performance in datagrid – when datagrid is being shown it is so slow that I can see one by one cells is drawn -datagrid contains about 35x40 of cells - they are generated through the odswierz_frekfencje() function (listed below)-
9
2718
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the code: <script runat="server"> Dim sqlConn As New SqlConnection(".....") Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) If Not (Page.IsPostBack) Then FillDataGrid()
0
2662
by: rn5a | last post by:
Suppose I have the following DataGrid: <asp:DataGrid ID="dgUsers" OnUpdateCommand="UpdateDG" runat="server"> <Columns> <TemplateColumn HeaderText="NAME"> <ItemTemplate> <asp:Label ID="lblFName" runat="server"><%# Container.DataItem("FName") %></asp:Label> </ItemTemplate> <EditItemTemplate>
0
8507
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8773
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7589
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5792
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4302
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2938
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1927
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.