By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Datagrid edit question

P: n/a
Leo
I have a datagrid with the first column as a Edit,Update,Cancel button
column. The other 5 columns are template columns. When I click the Edit
button in IE6 the row correctly displays the controls defined in the
<EditItemTemplate> however when I right click and do a view source I cannot
find any of the input textboxes in the source. I have used the
ItemDatabound event to try to attach javascript to the textboxes and in
debug mode while stepping through it seems to find the controls and add the
attributes but they never show up in the view source. Here is the source
line for just the datarow that is in the edit mode:

<tr style="color:Black;background-color:#EEEEEE;">
<td style="color:Blue;">
<a href="javascript:__doPostBack('grdStaff$_ctl4$_ctl 0','')"
style="color:Blue;">Edit</a>
</td>
<td>
<span>Beck, John</span>
</td>
<td>
<span id="grdStaff__ctl4_lblLoginName">BeckJ</span>
</td>
<td>
<span id="grdStaff__ctl4_lblPassword">1235</span>
</td>
<td>
<span id="grdStaff__ctl4_lblEmail">Jo*******@sc.org</span>
</td>
<td align="Center">
<font face="Wingdings"><b></b></font>
</td>
</tr>

It looks like it is still showing the Edit button even though the row is
displayed in the edit mode in IE. I have done a find in the source for
"BeckJ" and this one row is the only place it is found which is the line
being edited. How is IE displaying the textboxes and is it possible to
attach javascript to them?
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Leo,

Look at Page.RegisterClientScriptBlock for information on how to attach
JavaScript to .NET server controls. If you want to get to the controls on the
server side, you will need to name the textboxes appropriately and use the
"FindControl" method to get to them.

Hope this helps.
Tony.

"Leo" wrote:
I have a datagrid with the first column as a Edit,Update,Cancel button
column. The other 5 columns are template columns. When I click the Edit
button in IE6 the row correctly displays the controls defined in the
<EditItemTemplate> however when I right click and do a view source I cannot
find any of the input textboxes in the source. I have used the
ItemDatabound event to try to attach javascript to the textboxes and in
debug mode while stepping through it seems to find the controls and add the
attributes but they never show up in the view source. Here is the source
line for just the datarow that is in the edit mode:

<tr style="color:Black;background-color:#EEEEEE;">
<td style="color:Blue;">
<a href="javascript:__doPostBack('grdStaff$_ctl4$_ctl 0','')"
style="color:Blue;">Edit</a>
</td>
<td>
<span>Beck, John</span>
</td>
<td>
<span id="grdStaff__ctl4_lblLoginName">BeckJ</span>
</td>
<td>
<span id="grdStaff__ctl4_lblPassword">1235</span>
</td>
<td>
<span id="grdStaff__ctl4_lblEmail">Jo*******@sc.org</span>
</td>
<td align="Center">
<font face="Wingdings"><b></b></font>
</td>
</tr>

It looks like it is still showing the Edit button even though the row is
displayed in the edit mode in IE. I have done a find in the source for
"BeckJ" and this one row is the only place it is found which is the line
being edited. How is IE displaying the textboxes and is it possible to
attach javascript to them?

Nov 19 '05 #2

P: n/a
Leo
I have already built a scripting.cs class that does this. I have used it to
attach the javascript to controls on pages but I can't get it to work with
this datagrid. As you can see I have named all my controls and I can find
them in the datagrid.itemdatabound event. I can even add the attributes
with Control.Attributes.Add("onmouseover", "javascript"), they just never
show up in the IE view source and never do anything. I tried building a
simple project with just a one row datagrid with an edit column and when it
is in edit mode in IE the <input> controls show up fine, they just don't in
this datagrid.

Here is a snippet of the HTML view of the .aspx:
<asp:TemplateColumn
HeaderText="Login">
<ItemTemplate>
<asp:Label
ID="lblLoginName"
runat="server"
Text='<%# DataBinder.Eval(Container.dataitem, "LoginName") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox
ID="txtLoginName"
runat="server"
width="95%"
Text='<%# DataBinder.Eval(Container.dataitem, "LoginName") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>

<asp:TemplateColumn
HeaderText="Password">
<ItemTemplate>
<asp:Label
ID="lblPassword"
runat="server"
Text='<%# DataBinder.Eval(Container.dataitem, "LoginPassword") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox
ID="txtPassword"
runat="server"
width="95%"
Text='<%# DataBinder.Eval(Container.dataitem, "LoginPassword") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>

"Tony John" <To******@discussions.microsoft.com> wrote in message
news:5D**********************************@microsof t.com...
Hi Leo,

Look at Page.RegisterClientScriptBlock for information on how to attach
JavaScript to .NET server controls. If you want to get to the controls on
the
server side, you will need to name the textboxes appropriately and use the
"FindControl" method to get to them.

Hope this helps.
Tony.

"Leo" wrote:
I have a datagrid with the first column as a Edit,Update,Cancel button
column. The other 5 columns are template columns. When I click the Edit
button in IE6 the row correctly displays the controls defined in the
<EditItemTemplate> however when I right click and do a view source I
cannot
find any of the input textboxes in the source. I have used the
ItemDatabound event to try to attach javascript to the textboxes and in
debug mode while stepping through it seems to find the controls and add
the
attributes but they never show up in the view source. Here is the source
line for just the datarow that is in the edit mode:

<tr style="color:Black;background-color:#EEEEEE;">
<td style="color:Blue;">
<a href="javascript:__doPostBack('grdStaff$_ctl4$_ctl 0','')"
style="color:Blue;">Edit</a>
</td>
<td>
<span>Beck, John</span>
</td>
<td>
<span id="grdStaff__ctl4_lblLoginName">BeckJ</span>
</td>
<td>
<span id="grdStaff__ctl4_lblPassword">1235</span>
</td>
<td>
<span id="grdStaff__ctl4_lblEmail">Jo*******@sc.org</span>
</td>
<td align="Center">
<font face="Wingdings"><b></b></font>
</td>
</tr>

It looks like it is still showing the Edit button even though the row is
displayed in the edit mode in IE. I have done a find in the source for
"BeckJ" and this one row is the only place it is found which is the line
being edited. How is IE displaying the textboxes and is it possible to
attach javascript to them?

Nov 19 '05 #3

P: n/a
I have attached the Javascript to the controls on the Page_Load event and it
works for me. Are you doing the same?

"Leo" wrote:
I have already built a scripting.cs class that does this. I have used it to
attach the javascript to controls on pages but I can't get it to work with
this datagrid. As you can see I have named all my controls and I can find
them in the datagrid.itemdatabound event. I can even add the attributes
with Control.Attributes.Add("onmouseover", "javascript"), they just never
show up in the IE view source and never do anything. I tried building a
simple project with just a one row datagrid with an edit column and when it
is in edit mode in IE the <input> controls show up fine, they just don't in
this datagrid.

Here is a snippet of the HTML view of the .aspx:
<asp:TemplateColumn
HeaderText="Login">
<ItemTemplate>
<asp:Label
ID="lblLoginName"
runat="server"
Text='<%# DataBinder.Eval(Container.dataitem, "LoginName") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox
ID="txtLoginName"
runat="server"
width="95%"
Text='<%# DataBinder.Eval(Container.dataitem, "LoginName") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>

<asp:TemplateColumn
HeaderText="Password">
<ItemTemplate>
<asp:Label
ID="lblPassword"
runat="server"
Text='<%# DataBinder.Eval(Container.dataitem, "LoginPassword") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox
ID="txtPassword"
runat="server"
width="95%"
Text='<%# DataBinder.Eval(Container.dataitem, "LoginPassword") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>

"Tony John" <To******@discussions.microsoft.com> wrote in message
news:5D**********************************@microsof t.com...
Hi Leo,

Look at Page.RegisterClientScriptBlock for information on how to attach
JavaScript to .NET server controls. If you want to get to the controls on
the
server side, you will need to name the textboxes appropriately and use the
"FindControl" method to get to them.

Hope this helps.
Tony.

"Leo" wrote:
I have a datagrid with the first column as a Edit,Update,Cancel button
column. The other 5 columns are template columns. When I click the Edit
button in IE6 the row correctly displays the controls defined in the
<EditItemTemplate> however when I right click and do a view source I
cannot
find any of the input textboxes in the source. I have used the
ItemDatabound event to try to attach javascript to the textboxes and in
debug mode while stepping through it seems to find the controls and add
the
attributes but they never show up in the view source. Here is the source
line for just the datarow that is in the edit mode:

<tr style="color:Black;background-color:#EEEEEE;">
<td style="color:Blue;">
<a href="javascript:__doPostBack('grdStaff$_ctl4$_ctl 0','')"
style="color:Blue;">Edit</a>
</td>
<td>
<span>Beck, John</span>
</td>
<td>
<span id="grdStaff__ctl4_lblLoginName">BeckJ</span>
</td>
<td>
<span id="grdStaff__ctl4_lblPassword">1235</span>
</td>
<td>
<span id="grdStaff__ctl4_lblEmail">Jo*******@sc.org</span>
</td>
<td align="Center">
<font face="Wingdings"><b></b></font>
</td>
</tr>

It looks like it is still showing the Edit button even though the row is
displayed in the edit mode in IE. I have done a find in the source for
"BeckJ" and this one row is the only place it is found which is the line
being edited. How is IE displaying the textboxes and is it possible to
attach javascript to them?


Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.