473,320 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to access controls which are placed in datagrid Header Templete

Hi,
I am B.V.Ramesh Babu.I am working as software programmer using .net.We
are using asp.net1.1 with C#.net as coding.I hope that i will get the
required support from you.
Here is my requirement.
I am using datagrid control.In that data grid I put checkboxes in both
item templete and in Header templete.My requirement is is if i check
any checkbox in itemtemplete and click delete button those records will
be deleted.In another way I check the check box in the Header templete
The all check boxes will be checked and if dechecked all check boxes
will be deleted.
For that purpose I took check box in header templete.But I am unable
access the check box in the header templete of the datagrid
I use the following html code.
---------------------------------------------------------HTML-------------------------------------------------
<table>
<TR>
<TD>
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 176px;
POSITION: absolute; TOP: 104px"
runat="server" Width="688px" Height="248px"
AutoGenerateColumns="False">
<AlternatingItemStyle BackColor="#FFFFCC"></AlternatingItemStyle>
<ItemStyle BackColor="#FF99CC"></ItemStyle>
<HeaderStyle Font-Bold="True" BackColor="#CCFFFF"></HeaderStyle>
<Columns>
<asp:TemplateColumn>
<HeaderTemplate>
<asp:CheckBox id="CheckBox2" runat="server"></asp:CheckBox>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="BankID" ReadOnly="True"
HeaderText="BankID"></asp:BoundColumn>
<asp:BoundColumn DataField="BankName"
HeaderText="BankName"></asp:BoundColumn>
<asp:BoundColumn DataField="CountryName"
HeaderText="Country"></asp:BoundColumn>
<asp:BoundColumn DataField="CityName"
HeaderText="City"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
</TD>
</TR>
</table>
---------------------------------------------------------HTML-------------------------------------------------

I use follwing C# code for accessing the check box in header control
---------------------------------------------------------C#-----------------------------------------------------
PAGELOAD
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
bindgrid();
}
foreach(DataGridItem dgi in DataGrid1.Items)
{
CheckBox Hchk=(CheckBox)dgi.FindControl("CheckBox2");
if(Hchk.Checked)
{
Response.Write("HEDER CXHECK BOX IS CHECKED");
}
}
}
BINDGRID FUNCTION
private void bindgrid()
{
SqlDataAdapter da=new SqlDataAdapter("select * from BANKS1",con);
da.Fill(ds,"Banks");
DataGrid1.DataSource=ds.Tables["Banks"];
DataGrid1.DataBind();
}
---------------------------------------------------------C#-----------------------------------------------------
Please help me in this regard.
I would like to access the control which is placed in Headeritem of the
datagrid.
-Thanks in Advance,
Ramesh Babu

Aug 31 '06 #1
0 1461

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

Similar topics

2
by: | last post by:
Hello All, I am having a lot of difficulty trying to bind a templated column, that is programmatically created for a datagrid, to a datasource column. I have a datasource containing 2 columns,...
1
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...
1
by: Raghuram | last post by:
Hi, i have a DataGrid by Name : datagrid1 and in that i had created one templete Column and Added a new datagrid : datagrid2. Now i want to access that datagrid2 how is it possiable. and populate...
1
by: basulasz | last post by:
I want to get the selected value of a DropDownList which is in a Header Templete of a templete column. I want to get it in an arbitrary location of the code, i mean not from...
0
by: Joey | last post by:
Hello, I need to be able to access the linkbuttons that are used for paging inside a datagrid so I can set the style for what eventually becomes the client-side html anchor tags. I have read...
3
by: MDB | last post by:
I have a datagrid with an drop down list item templete and was wondering how I get the value of this? The datagrid is called dgProducts and the drop down list is called ddQty. Thanks in Advance...
15
by: Arpan | last post by:
Consider the following code which retrieves data from a SQL Server 2005 DB table & displays it in a DataGrid: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)...
4
by: _MC_ | last post by:
Hi, I'm unable to access values in my Datagrid. Datagrid thinks it hase only 1 Cell. So here it is: The Datagrid is binded in PageLoad, AutoGenerateColumns is false, Columns are added on...
1
by: RN1 | last post by:
Consider the following DataGrid: -------------------------------------------------------------------------------- <asp:DataGrid ID="dgMarks" AutoGenerateColumns="false" runat="server"> <Columns>...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

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.