Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Prasad #1
Re: Problem to Access web control on the DataGrid Header
Hi
The Items Collection of DataGrid does not hold Header and Footer. So to
access the Control you need to handle ItemCreated event.
HTH
Prasad
"Robert Hui" <anonymous@devdex.com> wrote in message
news:eHWq7v3RDHA.3880@tk2msftngp13.phx.gbl...>
> Hi
>
> I have created a textbox control in the Datagrid column header. Like
> this:
>
> In form.aspx file:
> <asp:DataGrid id="grdHeader">
> <Column>
> <asp:TemplateColumn>
> <ItemTemplate>
> <%# DataBinder.Eval(Container.DataItem,"FieldName")%>
> </ItemTemplate>
> <HeaderTemplate>
> <asp:TextBox id="txtTest" Runat="server">
> </asp:TextBox>
> </HeaderTemplate>
>
> </asp:TemplateColumn>
> </Column>
> </asp:DataGrid>
>
> In form.aspx.cs file:
>
> Put on htmlServerControl such as "cmdClick"
>
> On cmbClick's ServerClick event, I have wrote code like:
>
> grdHeader.Items[0].FindControl("txtTest")
>
> or
>
> foreach (DataGridItem di in grdHeader.Items)
> {
> TextBox txtValue=(TextBox)di.FinControl("txtTest");
> string strValue=txtValue.Text;
> }
>
> Both of them are failed, the FindControl statement reture null
> reference.
>
> I also have tried decalre same name of control in form.aspx.cs file
> class definition. Then call like that:
>
> strValue=txtTest.Text;
>
> But the result still same.
>
> Could anyone know how to implment this? I know the DataGridItem not
> includes header, so the above statement will fail, but which I can use
> to get the value that entered from client side.
>
> Thanks in advance.
>
> Regards
>
> Robert
>
>
>
>
>
>
>
> *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> Don't just participate in USENET...get rewarded for it!
Prasad Guest
-
access control in header template
I got a label control which is dynamically created inside the headerTemplate of template column. And it is part of the datagrid. Please teach... -
Problem creating custom header when datagrid AllowPaging=true
I have very strange problem with custom header. I create this in PreRender event, and if datagrid AllowPaging property is false, result looks like... -
get more control on datagrid header (?)
Dear all, I add more header's row on runtime using ItemCreate() and add DataGridItem(0, 0, ListItemType.Header) to get more header row. and... -
How do access a datagrid control in Page_load
Hi, I have the following setup A datagrid containing a Table(template column) The table contains a Dropdownlist. I want to bind the dropdown... -
Control derived from datagrid, problem with adding other control and databinding (VB)
I all, my employer required me to add a bunch of control to a datagrid (such as a drop down list on top corner to select page size and prev, bunch...



Reply With Quote

