Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Template Columns Controls

Reply
Thread Tools

Template Columns Controls

 
 
=?Utf-8?B?UmFlZCBTYXdhbGhh?=
Guest
Posts: n/a
 
      10-29-2005
I have datagrid , i edited the template column by adding checkbox on in
templateheader and one in templateitem

the problem i have i can not get access to the checkbox at runtime , i did
this to get them but not worked:

string ClientID = "";
foreach(DataGridItem item in dgAddresses.Items)
{

CheckBox chk = item.FindControl("chbAll") as CheckBox;
if(chk != null)
ClientID = chk.ID;
else continue;

}

how can i get access to them?
 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      10-29-2005
It should have worked. Make sure you databind the datagrid before you
attempt looping through its items and also add a condition to examine the
datagrid itemtype first, e.g.
foreach (DataGridItem item in dgAddresses)
{
switch (item.ItemType )
{
case ListItemType.Header:
// find the chbAll control
break;
case ListItemType.Item:
//find the individual controls
break;
}
}

I have a sample where I used the event handler of the checkbox to process
whatever action needed instead of looping through the entire datagrid:
http://www.societopia.net/Samples/Da...olsEvents.aspx


--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"Raed Sawalha" wrote:

> I have datagrid , i edited the template column by adding checkbox on in
> templateheader and one in templateitem
>
> the problem i have i can not get access to the checkbox at runtime , i did
> this to get them but not worked:
>
> string ClientID = "";
> foreach(DataGridItem item in dgAddresses.Items)
> {
>
> CheckBox chk = item.FindControl("chbAll") as CheckBox;
> if(chk != null)
> ClientID = chk.ID;
> else continue;
>
> }
>
> how can i get access to them?

 
Reply With Quote
 
 
 
 
S.M. Altaf [MVP]
Guest
Posts: n/a
 
      10-29-2005

Hi,

You may also want to change this:

CheckBox chk = item.FindControl("chbAll") as CheckBox;

to:

CheckBox chk = (CheckBox)item.FindControl("chbAll");

I can't say I've ever heard of "as" in C#.

HTH,
Altaf





--------------------------------------------------------------------------------

All that glitters has a high refractive index.
www.mendhak.com
"Phillip Williams" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
It should have worked. Make sure you databind the datagrid before you
attempt looping through its items and also add a condition to examine the
datagrid itemtype first, e.g.
foreach (DataGridItem item in dgAddresses)
{
switch (item.ItemType )
{
case ListItemType.Header:
// find the chbAll control
break;
case ListItemType.Item:
//find the individual controls
break;
}
}

I have a sample where I used the event handler of the checkbox to process
whatever action needed instead of looping through the entire datagrid:
http://www.societopia.net/Samples/Da...olsEvents.aspx


--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"Raed Sawalha" wrote:

> I have datagrid , i edited the template column by adding checkbox on in
> templateheader and one in templateitem
>
> the problem i have i can not get access to the checkbox at runtime , i did
> this to get them but not worked:
>
> string ClientID = "";
> foreach(DataGridItem item in dgAddresses.Items)
> {
>
> CheckBox chk = item.FindControl("chbAll") as CheckBox;
> if(chk != null)
> ClientID = chk.ID;
> else continue;
>
> }
>
> how can i get access to them?

 
Reply With Quote
 
Patrick.O.Ige
Guest
Posts: n/a
 
      10-30-2005
Yeah Altaf
"S.M. Altaf [MVP]" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...

Hi,

You may also want to change this:

CheckBox chk = item.FindControl("chbAll") as CheckBox;

to:

CheckBox chk = (CheckBox)item.FindControl("chbAll");

I can't say I've ever heard of "as" in C#.

HTH,
Altaf





------------------------------------------------------------------------------

All that glitters has a high refractive index.
www.mendhak.com
"Phillip Williams" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
It should have worked. Make sure you databind the datagrid before you
attempt looping through its items and also add a condition to examine the
datagrid itemtype first, e.g.
foreach (DataGridItem item in dgAddresses)
{
switch (item.ItemType )
{
case ListItemType.Header:
// find the chbAll control
break;
case ListItemType.Item:
//find the individual controls
break;
}
}

I have a sample where I used the event handler of the checkbox to process
whatever action needed instead of looping through the entire datagrid:
http://www.societopia.net/Samples/Da...olsEvents.aspx


--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"Raed Sawalha" wrote:

> I have datagrid , i edited the template column by adding checkbox on in
> templateheader and one in templateitem
>
> the problem i have i can not get access to the checkbox at runtime , i did
> this to get them but not worked:
>
> string ClientID = "";
> foreach(DataGridItem item in dgAddresses.Items)
> {
>
> CheckBox chk = item.FindControl("chbAll") as CheckBox;
> if(chk != null)
> ClientID = chk.ID;
> else continue;
>
> }
>
> how can i get access to them?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
template columns and bound columns in gridview Vinki ASP .Net Web Controls 2 04-25-2007 04:22 PM
Capture events on controls in template columns daniel kurtz ASP .Net Datagrid Control 3 10-11-2005 03:11 PM
convert rows to columns and columns to rows helpful sql ASP .Net 0 05-19-2005 06:03 PM
ClintID does not work for datagrid template columns controls Tudor ASP .Net Datagrid Control 1 07-15-2003 12:01 PM
ClintID does not work for datagrid template columns controls Tudor ASP .Net Web Controls 1 07-15-2003 11:35 AM



Advertisments