473,666 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Controls in HeaderTemplate

Hi!

Does anyone know how to get the text in textbox field which is in
HeaderTemplate of a DataGrid?
In the following code, I can not get text of "tbName". I typed something in
that box. I can get
tbName control but the text is empty.

Thanks a lot!

Yan

=============== ===== asp =============== =============== =============== ==
<asp:datagrid Autogeneratecol umns="false" id="dgList" runat="server"
DataKeyField="I D">
<Columns>
<asp:TemplateCo lumn>
<ItemStyle></ItemStyle>
<ItemTemplate >
<asp:LinkButt on Runat="server" CommandName="On NameClicked">
<%# DataBinder.Eval (Container.Data Item, "NAME") %>
</asp:LinkButton>
</ItemTemplate>
<HeaderTemplate >
<table>
<tr>
<td>
<asp:LinkButt on Runat="server" ID="btName"
OnCommand="OnNa meSortClicked" CommandArgument ="NAME">Name </asp:LinkButton>
<asp:Label Runat="server" ID="lbNameSort" ></asp:Label>
</td>
<tr>
<td>
<asp:TextBox Runat="server" ID="tbName"
EnableViewState ="True"></asp:TextBox>
</td>
</tr>
</table>
</HeaderTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:datagrid>
=============== ========== sever =============== =============== =========
public void OnItemDataBound (object sender, DataGridItemEve ntArgs e) {
if (e.Item.ItemTyp e == ListItemType.He ader) {
for (int i = 0; i < m_dgList.Column s.Count; ++i) {
Control aControl = null;
if (e.Item.Cells[i].HasControls()) {
aControl = e.Item.Cells[i].FindControl("t bName");
if (aControl != null) {
TextBox tbTemp = (TextBox)aContr ol; // I
reach here
if (tbTemp.Text != null && tbTemp.Text.Len gth > 0) {
tbTemp.Text = "Got it!";
//never reach here!!!!
}
}
}
}
}
}
Nov 18 '05 #1
5 2290
Hi, Yan Wang,

The condition

if (tbTemp.Text != null && tbTemp.Text.Len gth > 0)

is supposed to be false on the first request (when IsPostBack is false)
because the control is added like this:

<asp:TextBox Runat="server" ID="tbName" EnableViewState ="True"/>

Try to set the Text property in order to make the condition if (tbTemp.Text
!= null && tbTemp.Text.Len gth > 0) true.

Hope this helps
Martin

"Yan Wang" <yw*******@shaw .ca> wrote in message
news:RL3hc.1867 59$oR5.176815@p d7tw3no...
Hi!

Does anyone know how to get the text in textbox field which is in
HeaderTemplate of a DataGrid?
In the following code, I can not get text of "tbName". I typed something in that box. I can get
tbName control but the text is empty.

Thanks a lot!

Yan

=============== ===== asp =============== =============== =============== ==
<asp:datagrid Autogeneratecol umns="false" id="dgList" runat="server"
DataKeyField="I D">
<Columns>
<asp:TemplateCo lumn>
<ItemStyle></ItemStyle>
<ItemTemplate >
<asp:LinkButt on Runat="server" CommandName="On NameClicked">
<%# DataBinder.Eval (Container.Data Item, "NAME") %>
</asp:LinkButton>
</ItemTemplate>
<HeaderTemplate >
<table>
<tr>
<td>
<asp:LinkButt on Runat="server" ID="btName"
OnCommand="OnNa meSortClicked" CommandArgument ="NAME">Name </asp:LinkButton>
<asp:Label Runat="server" ID="lbNameSort" ></asp:Label>
</td>
<tr>
<td>
<asp:TextBox Runat="server" ID="tbName"
EnableViewState ="True"></asp:TextBox>
</td>
</tr>
</table>
</HeaderTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:datagrid>
=============== ========== sever =============== =============== =========
public void OnItemDataBound (object sender, DataGridItemEve ntArgs e) {
if (e.Item.ItemTyp e == ListItemType.He ader) {
for (int i = 0; i < m_dgList.Column s.Count; ++i) {
Control aControl = null;
if (e.Item.Cells[i].HasControls()) {
aControl = e.Item.Cells[i].FindControl("t bName");
if (aControl != null) {
TextBox tbTemp = (TextBox)aContr ol; // I
reach here
if (tbTemp.Text != null && tbTemp.Text.Len gth > 0) {
tbTemp.Text = "Got it!";
//never reach here!!!!
}
}
}
}
}
}

Nov 18 '05 #2
Hi!

You are right. But still I can not solve the problem. I try to catch
"OnItemDataBoun d" event is only raised when IsPostBack is true.
Same as OnItemCreate event. So I still can not get the text which I typed
in. I also notice, I can not make tbName instantialize
at codebhind class.(I use "protected TextBox tbName;" in class, it is always
NULL).
Is that because MS only want all stuff in datagrid to be shown to page only?
Any idea how to get content of textbox in
HeaderTemplate but that content is what typed from user not from program? Or
I have to go back as normal html input tag for
that textbox?

Thanks for your help!

Yan

"Martin Dechev" <de*******@hotm ail.com> wrote in message
news:em******** ******@TK2MSFTN GP09.phx.gbl...
Hi, Yan Wang,

The condition

if (tbTemp.Text != null && tbTemp.Text.Len gth > 0)

is supposed to be false on the first request (when IsPostBack is false)
because the control is added like this:

<asp:TextBox Runat="server" ID="tbName" EnableViewState ="True"/>

Try to set the Text property in order to make the condition if (tbTemp.Text != null && tbTemp.Text.Len gth > 0) true.

Hope this helps
Martin

"Yan Wang" <yw*******@shaw .ca> wrote in message
news:RL3hc.1867 59$oR5.176815@p d7tw3no...
Hi!

Does anyone know how to get the text in textbox field which is in
HeaderTemplate of a DataGrid?
In the following code, I can not get text of "tbName". I typed something

in
that box. I can get
tbName control but the text is empty.

Thanks a lot!

Yan

=============== ===== asp =============== =============== =============== ==
<asp:datagrid Autogeneratecol umns="false" id="dgList" runat="server"
DataKeyField="I D">
<Columns>
<asp:TemplateCo lumn>
<ItemStyle></ItemStyle>
<ItemTemplate >
<asp:LinkButt on Runat="server" CommandName="On NameClicked">
<%# DataBinder.Eval (Container.Data Item, "NAME") %>
</asp:LinkButton>
</ItemTemplate>
<HeaderTemplate >
<table>
<tr>
<td>
<asp:LinkButt on Runat="server" ID="btName"
OnCommand="OnNa meSortClicked" CommandArgument ="NAME">Name </asp:LinkButton> <asp:Label Runat="server" ID="lbNameSort" ></asp:Label>
</td>
<tr>
<td>
<asp:TextBox Runat="server" ID="tbName"
EnableViewState ="True"></asp:TextBox>
</td>
</tr>
</table>
</HeaderTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:datagrid>
=============== ========== sever =============== =============== =========
public void OnItemDataBound (object sender, DataGridItemEve ntArgs e) {
if (e.Item.ItemTyp e == ListItemType.He ader) {
for (int i = 0; i < m_dgList.Column s.Count; ++i) {
Control aControl = null;
if (e.Item.Cells[i].HasControls()) {
aControl = e.Item.Cells[i].FindControl("t bName");
if (aControl != null) {
TextBox tbTemp = (TextBox)aContr ol; // I
reach here
if (tbTemp.Text != null && tbTemp.Text.Len gth > 0) {
tbTemp.Text = "Got it!";
//never reach here!!!!
}
}
}
}
}
}


Nov 18 '05 #3
Hi, Yan,

Maybe this code can help you because it is working for me:

Listing <test.aspx>:

<%@ Page language="C#" inherits="test_ aspx" %>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en"
"http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test</title>
</head>
<body>
<form id="form1" method="post" runat="server">
<asp:datagrid id="DataGrid1" runat="server"
autogeneratecol umns="False" onitemcreated=" DataGrid1_ItemC reated">
<columns>
<asp:templateco lumn>
<itemtemplate >
<asp:linkbutt on runat="server" commandname="On NameClicked" id="Linkbutton1 ">
<%# DataBinder.Eval (Container.Data Item, "column1") %>
</asp:linkbutton>
</itemtemplate>
<headertemplate >
<table>
<tr>
<td>
<asp:textbox runat="server" id="tbName"
enableviewstate ="True"/>
</td>
</tr>
</table>
</headertemplate>
</asp:templatecol umn>
</columns>
</asp:datagrid>
</form>
</body>
</html>

Listing <test_aspx.cs >:

using System;

public class test_aspx : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Data Grid DataGrid1;

protected void Page_Load(objec t s, EventArgs e)
{
if(!IsPostBack)
{
System.Data.Dat aTable dt =
new System.Data.Dat aTable();
System.Data.Dat aRow dr;
dt.Columns.Add( "column1", typeof(string)) ;
dr = dt.NewRow();
dr[0] = "One";
dt.Rows.Add(dr) ;
dr = dt.NewRow();
dr[0] = "Two";
dt.Rows.Add(dr) ;
dr = dt.NewRow();
dr[0] = "Three";
dt.Rows.Add(dr) ;
dr = dt.NewRow();
dr[0] = "Four";
dt.Rows.Add(dr) ;
dr = dt.NewRow();
dr[0] = "Five";
dt.Rows.Add(dr) ;
DataGrid1.DataS ource =
dt.DefaultView;
DataGrid1.DataB ind();
}
}

protected void DataGrid1_ItemC reated(object s,
System.Web.UI.W ebControls.Data GridItemEventAr gs e)
{
if(e.Item.ItemT ype ==
System.Web.UI.W ebControls.List ItemType.Header )
{
System.Web.UI.W ebControls.Text Box tbName =
e.Item.FindCont rol("tbName") as
System.Web.UI.W ebControls.Text Box;
if(tbName != null)
tbName.Text = "Gotcha!";
}
}
}

Greetings
Martin
"Yan Wang" <yw*******@shaw .ca> wrote in message
news:FO9hc.1759 07$Pk3.74406@pd 7tw1no...
Hi!

You are right. But still I can not solve the problem. I try to catch
"OnItemDataBoun d" event is only raised when IsPostBack is true.
Same as OnItemCreate event. So I still can not get the text which I typed
in. I also notice, I can not make tbName instantialize
at codebhind class.(I use "protected TextBox tbName;" in class, it is always NULL).
Is that because MS only want all stuff in datagrid to be shown to page only? Any idea how to get content of textbox in
HeaderTemplate but that content is what typed from user not from program? Or I have to go back as normal html input tag for
that textbox?

Thanks for your help!

Yan

"Martin Dechev" <de*******@hotm ail.com> wrote in message
news:em******** ******@TK2MSFTN GP09.phx.gbl...
Hi, Yan Wang,

The condition

if (tbTemp.Text != null && tbTemp.Text.Len gth > 0)

is supposed to be false on the first request (when IsPostBack is false)
because the control is added like this:

<asp:TextBox Runat="server" ID="tbName" EnableViewState ="True"/>

Try to set the Text property in order to make the condition if

(tbTemp.Text
!= null && tbTemp.Text.Len gth > 0) true.

Hope this helps
Martin

"Yan Wang" <yw*******@shaw .ca> wrote in message
news:RL3hc.1867 59$oR5.176815@p d7tw3no...
Hi!

Does anyone know how to get the text in textbox field which is in
HeaderTemplate of a DataGrid?
In the following code, I can not get text of "tbName". I typed something
in
that box. I can get
tbName control but the text is empty.

Thanks a lot!

Yan

=============== ===== asp
=============== =============== =============== == <asp:datagrid Autogeneratecol umns="false" id="dgList" runat="server"
DataKeyField="I D">
<Columns>
<asp:TemplateCo lumn>
<ItemStyle></ItemStyle>
<ItemTemplate >
<asp:LinkButt on Runat="server" CommandName="On NameClicked">
<%# DataBinder.Eval (Container.Data Item, "NAME") %>
</asp:LinkButton>
</ItemTemplate>
<HeaderTemplate >
<table>
<tr>
<td>
<asp:LinkButt on Runat="server" ID="btName"
OnCommand="OnNa meSortClicked"

CommandArgument ="NAME">Name </asp:LinkButton> <asp:Label Runat="server" ID="lbNameSort" ></asp:Label>
</td>
<tr>
<td>
<asp:TextBox Runat="server" ID="tbName"
EnableViewState ="True"></asp:TextBox>
</td>
</tr>
</table>
</HeaderTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:datagrid>
=============== ========== sever =============== =============== ========= public void OnItemDataBound (object sender, DataGridItemEve ntArgs e) {
if (e.Item.ItemTyp e == ListItemType.He ader) {
for (int i = 0; i < m_dgList.Column s.Count; ++i) {
Control aControl = null;
if (e.Item.Cells[i].HasControls()) {
aControl = e.Item.Cells[i].FindControl("t bName");
if (aControl != null) {
TextBox tbTemp = (TextBox)aContr ol; // I reach here
if (tbTemp.Text != null && tbTemp.Text.Len gth > 0) {
tbTemp.Text = "Got it!";
//never reach here!!!!
}
}
}
}
}
}




Nov 18 '05 #4
Hi! Martin:

Thanks a lot for your reply. From code here, I think you put "Gotcha" in
code. What I want
is that I want to get the content of that textbox. Say, I type in something
to that textbox from
browser. Then I click "One" (a link button in datagrid item). The page is
posted back to server.
Now, I want to get the content of TextBox in HeaderTemplate at this time.
But I find, I
can not get it. It always return me empty string.

Do you know how to solve it?

Thanks a lot!

Yan
"Martin Dechev" <de*******@hotm ail.com> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
Hi, Yan,

Maybe this code can help you because it is working for me:

Listing <test.aspx>:

<%@ Page language="C#" inherits="test_ aspx" %>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en"
"http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test</title>
</head>
<body>
<form id="form1" method="post" runat="server">
<asp:datagrid id="DataGrid1" runat="server"
autogeneratecol umns="False" onitemcreated=" DataGrid1_ItemC reated">
<columns>
<asp:templateco lumn>
<itemtemplate >
<asp:linkbutt on runat="server" commandname="On NameClicked" id="Linkbutton1 "> <%# DataBinder.Eval (Container.Data Item, "column1") %>
</asp:linkbutton>
</itemtemplate>
<headertemplate >
<table>
<tr>
<td>
<asp:textbox runat="server" id="tbName"
enableviewstate ="True"/>
</td>
</tr>
</table>
</headertemplate>
</asp:templatecol umn>
</columns>
</asp:datagrid>
</form>
</body>
</html>

Listing <test_aspx.cs >:

using System;

public class test_aspx : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Data Grid DataGrid1;

protected void Page_Load(objec t s, EventArgs e)
{
if(!IsPostBack)
{
System.Data.Dat aTable dt =
new System.Data.Dat aTable();
System.Data.Dat aRow dr;
dt.Columns.Add( "column1", typeof(string)) ;
dr = dt.NewRow();
dr[0] = "One";
dt.Rows.Add(dr) ;
dr = dt.NewRow();
dr[0] = "Two";
dt.Rows.Add(dr) ;
dr = dt.NewRow();
dr[0] = "Three";
dt.Rows.Add(dr) ;
dr = dt.NewRow();
dr[0] = "Four";
dt.Rows.Add(dr) ;
dr = dt.NewRow();
dr[0] = "Five";
dt.Rows.Add(dr) ;
DataGrid1.DataS ource =
dt.DefaultView;
DataGrid1.DataB ind();
}
}

protected void DataGrid1_ItemC reated(object s,
System.Web.UI.W ebControls.Data GridItemEventAr gs e)
{
if(e.Item.ItemT ype ==
System.Web.UI.W ebControls.List ItemType.Header )
{
System.Web.UI.W ebControls.Text Box tbName =
e.Item.FindCont rol("tbName") as
System.Web.UI.W ebControls.Text Box;
if(tbName != null)
tbName.Text = "Gotcha!";
}
}
}

Greetings
Martin
"Yan Wang" <yw*******@shaw .ca> wrote in message
news:FO9hc.1759 07$Pk3.74406@pd 7tw1no...
Hi!

You are right. But still I can not solve the problem. I try to catch
"OnItemDataBoun d" event is only raised when IsPostBack is true.
Same as OnItemCreate event. So I still can not get the text which I typed
in. I also notice, I can not make tbName instantialize
at codebhind class.(I use "protected TextBox tbName;" in class, it is always
NULL).
Is that because MS only want all stuff in datagrid to be shown to page

only?
Any idea how to get content of textbox in
HeaderTemplate but that content is what typed from user not from

program? Or
I have to go back as normal html input tag for
that textbox?

Thanks for your help!

Yan

"Martin Dechev" <de*******@hotm ail.com> wrote in message
news:em******** ******@TK2MSFTN GP09.phx.gbl...
Hi, Yan Wang,

The condition

if (tbTemp.Text != null && tbTemp.Text.Len gth > 0)

is supposed to be false on the first request (when IsPostBack is false) because the control is added like this:

<asp:TextBox Runat="server" ID="tbName" EnableViewState ="True"/>

Try to set the Text property in order to make the condition if (tbTemp.Text
!= null && tbTemp.Text.Len gth > 0) true.

Hope this helps
Martin

"Yan Wang" <yw*******@shaw .ca> wrote in message
news:RL3hc.1867 59$oR5.176815@p d7tw3no...
> Hi!
>
> Does anyone know how to get the text in textbox field which is in
> HeaderTemplate of a DataGrid?
> In the following code, I can not get text of "tbName". I typed

something in
> that box. I can get
> tbName control but the text is empty.
>
> Thanks a lot!
>
> Yan
>
> =============== ===== asp =============== =============== =============== == > <asp:datagrid Autogeneratecol umns="false" id="dgList" runat="server"
> DataKeyField="I D">
> <Columns>
> <asp:TemplateCo lumn>
> <ItemStyle></ItemStyle>
> <ItemTemplate >
> <asp:LinkButt on Runat="server" CommandName="On NameClicked">
> <%# DataBinder.Eval (Container.Data Item, "NAME") %>
> </asp:LinkButton>
> </ItemTemplate>
> <HeaderTemplate >
> <table>
> <tr>
> <td>
> <asp:LinkButt on Runat="server" ID="btName"
> OnCommand="OnNa meSortClicked"

CommandArgument ="NAME">Name </asp:LinkButton>
> <asp:Label Runat="server" ID="lbNameSort" ></asp:Label>
> </td>
> <tr>
> <td>
> <asp:TextBox Runat="server" ID="tbName"
> EnableViewState ="True"></asp:TextBox>
> </td>
> </tr>
> </table>
> </HeaderTemplate>
> </asp:TemplateCol umn>
> </Columns>
> </asp:datagrid>
> =============== ========== sever =============== =============== ========= > public void OnItemDataBound (object sender, DataGridItemEve ntArgs e) { > if (e.Item.ItemTyp e == ListItemType.He ader) {
> for (int i = 0; i < m_dgList.Column s.Count; ++i) {
> Control aControl = null;
> if (e.Item.Cells[i].HasControls()) {
> aControl = e.Item.Cells[i].FindControl("t bName");
> if (aControl != null) {
> TextBox tbTemp = (TextBox)aContr ol;
// I > reach here
> if (tbTemp.Text != null && tbTemp.Text.Len gth > 0) {
> tbTemp.Text = "Got it!";
> //never reach here!!!!
> }
> }
> }
> }
> }
> }
>
>


Nov 18 '05 #5
Hi, Yan,

The only place I could get reference to the textbox in the header was the
OnItemCreated event. The problem is that it happens after the call to the
event handler of the LinkButtons Click event. Apart from this, the viewstate
gets loaded after the OnItemCreated event. So, the only way is to append
info in the both event handlers and then do the processing in a third event
handler - after the viewstate has been loaded. I chose the OnPreRender event
of the datagrid for this.

Well, this seems to be a dirty solution... But it is working

listing <text.aspx>:

<%@ Page language="C#" inherits="test_ aspx" %>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en"
"http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dt d ">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Test</title>
</head>
<body>
<form id="form1" method="post" runat="server">
<asp:datagrid id="DataGrid1" runat="server"
autogeneratecol umns="False"
onitemcreated=" DataGrid1_ItemC reated"
onprerender="Da taGrid1_PreRend er">
<columns>
<asp:templateco lumn>
<itemstyle></itemstyle>
<itemtemplate >
<asp:linkbutt on runat="server" id="Linkbutton1 "
oncommand="Link Button_Command" commandname="On NameClicked"
commandargument ='<%# DataBinder.Eval (Container.Data Item,"column1") %>'>
<%# DataBinder.Eval (Container.Data Item, "column1") %>
</asp:linkbutton>
</itemtemplate>
<headertemplate >
<table>
<tr>
<td>
<asp:textbox runat="server" id="tbName"/>
</td>
</tr>
</table>
</headertemplate>
</asp:templatecol umn>
</columns>
</asp:datagrid>
the posted value is:
<asp:literal id="Literal1" runat="server"> n/a</asp:literal>
</form>
</body>
</html>

listing <test_aspx.cs >:

using System;

public class test_aspx : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Data Grid DataGrid1;
protected System.Web.UI.W ebControls.Lite ral Literal1;

System.Web.UI.W ebControls.Text Box tb;
string _commandArg, _commandName;
bool _linkButtonClic ked;

protected void Page_Load(objec t s, EventArgs e)
{
if(!IsPostBack)
{
System.Data.Dat aTable dt = new System.Data.Dat aTable();
System.Data.Dat aRow dr;
dt.Columns.Add( "column1", typeof(string)) ;
dr = dt.NewRow();
dr[0] = "One";
dt.Rows.Add(dr) ;
dr = dt.NewRow();
dr[0] = "Two";
dt.Rows.Add(dr) ;
dr = dt.NewRow();
dr[0] = "Three";
dt.Rows.Add(dr) ;
dr = dt.NewRow();
dr[0] = "Four";
dt.Rows.Add(dr) ;
dr = dt.NewRow();
dr[0] = "Five";
dt.Rows.Add(dr) ;
DataGrid1.DataS ource = dt.DefaultView;
DataGrid1.DataB ind();
}
}

protected void LinkButton_Comm and(object s,
System.Web.UI.W ebControls.Comm andEventArgs e)
{
// Store the info in the private fields
// for the later processing:
_commandArg = (string)e.Comma ndArgument;
_commandName = e.CommandName;
_linkButtonClic ked = true;
}

protected void DataGrid1_ItemC reated(object s,
System.Web.UI.W ebControls.Data GridItemEventAr gs e)
{
if(e.Item.ItemT ype ==
System.Web.UI.W ebControls.List ItemType.Header )
{
System.Web.UI.W ebControls.Text Box tbName =
e.Item.FindCont rol("tbName") as
System.Web.UI.W ebControls.Text Box;
if(tbName != null)
{
if(!IsPostBack)
tbName.Text = "Gotcha";
// Let's store the reference to this ghost:
tb = tbName;
}
}
}

protected void DataGrid1_PreRe nder(object s, EventArgs e)
{
if(_linkButtonC licked)
{
DoProcessing();
}
}

void DoProcessing()
{
// Do here the actual processing here

Literal1.Text = tb.Text;
}
}

Hope this helps
Martin
"Yan Wang" <yw*******@shaw .ca> wrote in message
news:eimhc.1939 34$oR5.2582@pd7 tw3no...
Hi! Martin:

Thanks a lot for your reply. From code here, I think you put "Gotcha" in
code. What I want
is that I want to get the content of that textbox. Say, I type in something to that textbox from
browser. Then I click "One" (a link button in datagrid item). The page is
posted back to server.
Now, I want to get the content of TextBox in HeaderTemplate at this time.
But I find, I
can not get it. It always return me empty string.

Do you know how to solve it?

Thanks a lot!

Yan


Nov 18 '05 #6

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

Similar topics

8
7904
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the header of the datagrid in the "ItemDataBound" method of the grid. However, once, they are added in the grid, i seem to lose the event handler for the same control. Is there anyone who has tried this before and knows why this is hapenning ??
4
2260
by: Moojjoo | last post by:
Ok fellow C# developers: How do creat an instance of an object inside a dataset or datagrid. Example I need to have a placeholder inside a dataset. Any help would be great.
1
5239
by: SamIAm | last post by:
Hi I have a DataGrid called dgTraders 1 of the columns is a template column and this column has a Dropdown box in its HeaderTemplate section. The Dropdown box is called selCities. How do I access this DropDown box at runtime? <asp:datagrid id="dgTraders" runat="server" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="4" GridLines="Vertical" ForeColor="Black" AutoGenerateColumns="False"...
1
1753
by: bill yeager | last post by:
I did some more debugging and found the following: 1) I placed the following code in the button event just to see if I could cycle thru the datagrid control collection: <code> Dim strhello As String Dim myDataListItem As DataListItem Dim myDatagridItem As DataGridItem Dim myCheckBox As CheckBox
6
375
by: Yan Wang | last post by:
Hi! Does anyone know how to get the text in textbox field which is in HeaderTemplate of a DataGrid? In the following code, I can not get text of "tbName". I typed something in that box. I can get tbName control but the text is empty. Thanks a lot!
1
1089
by: David | last post by:
Hello. I have one question about DataList control: I have one DaaList control on my page in which I put some controls, for example I put two labels in header section and five labels in items section. But now I can't access this labels from code by their names:( So how can I access controls in DataList control form code? Thank you.
2
1125
by: Tarun Mistry | last post by:
Hi everyone, a simple problem I hope you guys can help me with. I have a repeater control, within this i would like to place another server control. I.e. <asp:Repeater id="Repeater1" runat="server"> <HeaderTemplate></HeaderTemplate> <ItemTemplate>
4
2535
by: Rob Meade | last post by:
Hi all, I played with my first bit of AJAX the other week and was pleasantly surprised that I achieved my goal..now I'd like to try something else.. Question... If I have an updatePanel, and lets say I have a button as a trigger which runs a function in my code behind to add a textbox to the updatePanel, when the form is submitted does this control actually "exist" as such on the
1
7117
by: anjali.lourda | last post by:
Hi, We are trying to use the accordion control from ajaxcontroltoolkit by databinding to an sqldatasource. The accordion binds to the datasource perfectly. However, We are not able to access the controls or their values which were bound. Please let me know which is the away to access that Given below is the code. Please let me know if any further information is required. Regards, Anjali
1
2483
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
Hi. I have Mobile site that I'm building. My problem is that all of my pages are built as Mobile ASPX pages, but occasionally, I need to use controls which are not mobile. Most specifically, the "FileUpload" control. Now, most phones don't support this feature, but some do and for them I need to place and use this control. How can I insert a FileUpload control on a Mobile ASPX? Alex
0
8356
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
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8550
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7385
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...
1
6192
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5663
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
4198
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...
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1772
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.