B
Bonj
Hi
I've got an ASP.NET datagrid control, and in the footer, there is a series
of controls for typing in new values to add an item.
e.g.
<aspataGrid runat="Server".... >
<Columns>
...
<asp:TemplateColumn HeaderText="Name">
...
<FooterTemplate>
<asp:TextBox ID="txtNameAdd" Runat="server" Width="100%"
Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>' />
</FooterTemplate>
</asp:TemplateColumn>
<aspataGrid>
I'm using the following C# code to try to cause this to be selected, but it
is not working.
private void dg1_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
Control txtNameAdd = e.Item.FindControl("txtNameAdd");
if(txtNameAdd == null) Debug.WriteLine("txtNameAdd is null");
else
{
string js = string.Format("<script
language=\"javascript\">document.getElementById('{0}').select();
document.getElementById('{0}').focus();</script>",txtNameAdd.UniqueID);
Debug.WriteLine(js);
this.RegisterStartupScript("FocusNameAdd", js);
}
}
Any ideas as to what I can do to get it working?
I've got an ASP.NET datagrid control, and in the footer, there is a series
of controls for typing in new values to add an item.
e.g.
<aspataGrid runat="Server".... >
<Columns>
...
<asp:TemplateColumn HeaderText="Name">
...
<FooterTemplate>
<asp:TextBox ID="txtNameAdd" Runat="server" Width="100%"
Text='<%# DataBinder.Eval(Container.DataItem, "Name") %>' />
</FooterTemplate>
</asp:TemplateColumn>
<aspataGrid>
I'm using the following C# code to try to cause this to be selected, but it
is not working.
private void dg1_ItemCreated(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
Control txtNameAdd = e.Item.FindControl("txtNameAdd");
if(txtNameAdd == null) Debug.WriteLine("txtNameAdd is null");
else
{
string js = string.Format("<script
language=\"javascript\">document.getElementById('{0}').select();
document.getElementById('{0}').focus();</script>",txtNameAdd.UniqueID);
Debug.WriteLine(js);
this.RegisterStartupScript("FocusNameAdd", js);
}
}
Any ideas as to what I can do to get it working?