RE: innertext, javascript, datagrid, database update

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hell Lyners,

I missed picking on something in your response. You said that there were no
controls in the cell! Well, that explains it.

You need to have controls in the cell. If you are copying the data to a
cell that is databound to the grid, e.g. <asp:BoundColumn>, then you will
certainly not get its changed value upon postback because it is only
represented by a regular HTML <TD> tag that does not carry a value upon
posting back the form.

What you need to do is to use the <asp:TemplateColumn> as I did in the demo
I gave you its link to create an <Input> control on the form that can carry
the value back upon posting the form.

HTH
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"Lyners" wrote:

> Hi Phillip,
> I did the dgi.Cells(11).Controls.count and got a result of 0. I tried
> attributes too only to get a zero value for that. I don't have any controls
> in the datagrid cell. I am just loading the cells innertext with the users id
> for everyline that they modify.
>
> What I want to have happen is when they "update" the page via a postback
> that the cell value is passed back to the server so the code can update the
> userid field in the database. it appears that the cell is not passing back
> any values.
>
> Any suggestions on a better way to code this, or how to make this work?
>
>
> "Phillip Williams" wrote:
>
> > In VS.net, use the debugger to step through the code and examine the value of
> > dgi.Cells(11).Controls.count. Are there other controls in this cell? The
> > value you are looking for might be in one of those controls rather than in
> > the Text property of the cell itself.
> >
> > HTH
> > --
> > Phillip Williams
> > http://www.societopia.net
> > http://www.webswapp.com
> >
> >
> > "Lyners" wrote:
> >
> > > 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 see it on the screen.
> > >
> > > My java script code that populates the desired cell (this works);
> > >
> > > function AddRequesterName(imgObj)
> > > {
> > > imgObj.parentNode.parentNode.childNodes(8).innerText=UserName.outerText;
> > > }
> > >
> > > My code in the VB.NET that updates the database;
> > >
> > > Dim strEntryID As String = dgi.Cells(11).Text
> > >
> > > This works for all the other fields in the grid, except this one? The reason
> > > why it is cell(11) is because there are 3 hidden cells in the display.
> > >
> > > I have a felling it has something to do with innertext and referencing
> > > cell.text, but the cells attribute doesn't have an innertext.
> > >
> > > Any help on this?
> > >
> > > Lyners
> > >
.



Relevant Pages

  • Re: Complex DataGrid
    ... customize your datagrid at even the cell level. ... DataGridItemCollection) and actually add controls or remove controls from a ... Now when binding the datagrid, ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)
  • RE: innertext, javascript, datagrid, database update
    ... 1- add in your AddRequesterName javascript function the following line to ... > in the datagrid cell. ... Are there other controls in this cell? ... >>> when a user presses a button, or edits a certain field in a datagrid, another ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Custom DataGridColumn DataGridItems not saving to ViewState. Not Visible on Postback
    ... column cell be created in the InitializeCell method that is invoked ... child controls were being added to the cell only in ... > I created a custom DataGridColumn based on Marcie Robillard's MSDN ... > namespace PostbackError ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Custom DataGridColumn DataGridItems not saving to ViewState. Not Visible on Postback
    ... column cell be created in the InitializeCell method that is invoked ... child controls were being added to the cell only in ... > I created a custom DataGridColumn based on Marcie Robillard's MSDN ... > namespace PostbackError ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Find lost check box control in workbook
    ... you're right that the code you provided does select the cell ... the differences between controls from the Controls Toolbox menu and those old ... Having the controls appear in the Properties window of the code module would ... that lists all the shapes on the sheet unless they were made invisible (the ...
    (microsoft.public.excel.misc)