|
-
Feb 3rd, 2005, 03:47 AM
#1
Thread Starter
Fanatic Member
Disable button column in datagrid
I need to do this based on certain conditions, does anyone know how please?
-
Feb 3rd, 2005, 04:11 AM
#2
Re: Disable button column in datagrid
I have done something similar in C#. Will do?
PHP Code:
DropDownList ddl = (DropDownList)sender;
string strLeaveType = ddl.SelectedValue.ToString();
//strLeaveType will be my condition in the switch statement.
DataGridItemCollection DataGridItems = dgEditLeave.Items;
for (counter=0; counter<DataGridItems.Count; counter++)
{
DropDownList ddl1 = (DropDownList)DataGridItems[counter].FindControl("cmbLeaveType");
if(ddl1 != null)
{
if (ddl.ClientID == ddl1.ClientID)
break;
}
}
//Basically, I'm looking for a dropdown. I want to read the value in the dropdown and based upon that, I do certain things.
TextBox txtC = (TextBox)dgEditLeave.Items[counter].FindControl("txtComments");
//Now, I have "gotten" a textbox that I want to work with.
switch(strLeaveType)
{
case "CompensatoryOff":
txtC.Enabled=true;
break;
//and on and on....
While the second part of the code wouldn't be relevant, the first part is what's most important. You gain access to the controls in the datagrid. You can loop through and disable it, so on and so forth.
If you're doing this in the ItemDataBound event, then you'll be working with e.
HTH. If not, ask questions. It took me a while to understand this myself.
-
Feb 3rd, 2005, 04:55 AM
#3
Thread Starter
Fanatic Member
Re: Disable button column in datagrid
I sorta understand, at what point do I disable the control, from within the loop, i cant find the property to do it.
-
Feb 3rd, 2005, 05:31 AM
#4
Re: Disable button column in datagrid
As soon as you've assigned the button object, you can disable it.
-
Feb 3rd, 2005, 09:36 AM
#5
Thread Starter
Fanatic Member
Re: Disable button column in datagrid
cheers, i did it this way in the end.
VB Code:
If dvResults.Count <= dgSummary.PageSize Then
strTicker = dvResults.Count
End If
If dvResults.Count > dgSummary.PageSize Then
If dgSummary.CurrentPageIndex < dgSummary.PageCount - 1 Then
strTicker = dgSummary.PageSize
Else
strTicker = (dvResults.Count Mod dgSummary.PageCount)
End If
End If
strTicker = strTicker - 1
For z = 0 To strTicker
strAccount1 = wibble.Item(z).Cells(0).Controls(0)
straccount2 = strAccount1.Text
wibble.Item(z).Cells(0).Controls(0).Visible = False
wibble.Item(z).Cells(0).Text = straccount2
Next
End If
-
Feb 3rd, 2005, 09:59 AM
#6
Re: Disable button column in datagrid
Not sure what half of that is, especially the "wibble" . But as long as it works, it's good.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|