473,804 Members | 3,745 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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"
AutoGenerateCol umns="False">
<AlternatingIte mStyle BackColor="#FFF FCC"></AlternatingItem Style>
<ItemStyle BackColor="#FF9 9CC"></ItemStyle>
<HeaderStyle Font-Bold="True" BackColor="#CCF FFF"></HeaderStyle>
<Columns>
<asp:TemplateCo lumn>
<HeaderTemplate >
<asp:CheckBox id="CheckBox2" runat="server"> </asp:CheckBox>
</HeaderTemplate>
<ItemTemplate >
<asp:CheckBox id="CheckBox1" runat="server"> </asp:CheckBox>
</ItemTemplate>
</asp:TemplateCol umn>
<asp:BoundColum n DataField="Bank ID" ReadOnly="True"
HeaderText="Ban kID"></asp:BoundColumn >
<asp:BoundColum n DataField="Bank Name"
HeaderText="Ban kName"></asp:BoundColumn >
<asp:BoundColum n DataField="Coun tryName"
HeaderText="Cou ntry"></asp:BoundColumn >
<asp:BoundColum n DataField="City Name"
HeaderText="Cit y"></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(objec t sender, System.EventArg s e)
{
if(!IsPostBack)
{
bindgrid();
}
foreach(DataGri dItem 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,"Ban ks");
DataGrid1.DataS ource=ds.Tables["Banks"];
DataGrid1.DataB ind();
}
---------------------------------------------------------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 1484

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

Similar topics

2
2114
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, ID and VALUE. I would like to create a templated column in the datagrid that is bound to the VALUE column of the datasource.
1
1757
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
1
1272
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 the same datawhich is preset in the datagrid1. Raghuram
1
968
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 "DataGrid2_ItemDataBound" event. So, i need something like "DataGrid2.Items.... FindControl(.....". How can i do that? Thanks -- No Sign
0
1143
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 several posts about using the datagrid's PagerStyle property, but this solution is simply inadequate. This is because I need to be able to apply a CssStyle so that I can get at a:hover and other CSS properties. PagerStyle only applies the selected...
3
1330
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 MDB
15
2204
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) Dim dSet As DataSet Dim sqlConn As SqlConnection Dim sqlDapter As SqlDataAdapter sqlConn = New SqlConnection("Data Source=AD\SQLEXPRESS;Initial
4
2114
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 PageLoad like this: BoundColumn Bound_Column = new BoundColumn(); Bound_Column.DataField = name; ( + HeaderText,
1
2160
by: RN1 | last post by:
Consider the following DataGrid: -------------------------------------------------------------------------------- <asp:DataGrid ID="dgMarks" AutoGenerateColumns="false" runat="server"> <Columns> <asp:TemplateColumn> <HeaderTemplate> <asp:CheckBox ID="chkHeader" OnCheckedChanged="CheckUncheckAllRows" AutoPostBack="true" runat="server"/> </HeaderTemplate>
0
10583
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10337
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...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9160
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
7622
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
6854
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
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2995
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.