Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to hide the checkbox in datagrids one of the header cell

Status
Not open for further replies.

compu66

Programmer
Dec 19, 2007
71
US
Hi all,

I have a checkbox in one of the datagrid header cell.Dependending upon the user privileges I have to show or hide the checkbox in one of the header cell.


Please let me know the logic.

Thanks for the help in advance.
 
Please let me know the logic.
Isn't what you've written the logic? If you mean you need help implementing it, show what you have done so far and we can point you in the right direction.


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

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
this is the part i have written in codebehind:
If buserCanCompletetasks = True Then
e.Item.Attributes.Add("onload", "javascript:hideCheckbox(true)")


End If

this is the part in javascript:

function hideCheckbox(boolValue)
{
if(boolValue="false")
{
document.all['chkTaskComplete'].style.display = 'block';
here chkTaskcomplete is the id of the checkbox in the header cell


}

I dont know whether i am in the proper direction



 
So are you wanting to do this client-side (i.e. in javascript) rather than postback to the server? If so, I'd suggest providing the rendered HTML in a question to the javascript forum. The will help you with the actual javascript that you need, then we can show you how to implement it into an ASP.NET project (if necessary).


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

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
The way I would do it would to be to use the grid's ItemDataBound event. In there, first check if you are binding the header, then use .Findcontrol("your control") to get a reference to the object. Then set the visible property of the control as needed.
 
I am not particulat about how to do it.I just need to get the task done.
Can you kindly give your suggestion ,solving from code behind.I mean using asp.net and not javascript.

Thanks for your quick response.

 
the checkbox is the html.this findcontrol and visible will not have any effect on the code.so just i am trying to hide that particular header cell .
look at this code i did .
If buserCanCompletetasks = True Then
If e.Item.ItemType = ListItemType.Header Then
e.Item.Cells(11).Visible = True
End If
Else
If e.Item.ItemType = ListItemType.Header Then
e.Item.Cells(11).Visible = False
End If
End If
but the error in code is its removing that header cell having checkbox instead of hiding it.so as a result mismatch of header cell and the rest of the rows.

I belive i could explain in good way.if not let me know.
 
Are you trying to hide the "column" of the datagrid based on your flag, or are you trying to hide the checkbox in the "row" based on the flag?
 
trying to hide the html checkbox in the header cell, i dont think my code is doing that.At this point if you can guide that will help me.
Thx.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top