I need to do this based on certain conditions, does anyone know how please?
Printable View
I need to do this based on certain conditions, does anyone know how please?
I have done something similar in C#. Will do?
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.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....
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.
I sorta understand, at what point do I disable the control, from within the loop, i cant find the property to do it.
As soon as you've assigned the button object, you can disable it.
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
Not sure what half of that is, especially the "wibble" :ehh:. But as long as it works, it's good. :)