Hi,
I am having a condition that when there are no records in datagrid if user clicks ADD button, the footer should appear with a label as visible and textBox as invisible. If there r more records in grid, then after ADD button clicked, the textBox will be visible instead of label.
Any one can help me please.....
Thanks in advance.
Loading

nikshuklaPosted Dec 12, 2006, 10:03 AM
Do something like this.
For Each itm as DataGridItem in dg.Items
If Itm.ItemType = ListItemType.Footer Then
'Do your work here.
Exit For
End IF
Next
Hope this helps.
Regards,
shekhar pawarPosted Dec 8, 2006, 4:31 AM
Hi,
void btnAdd_Click(object sender, System.EventArgs e){Thanks for reply... But I tried following code ,it's not working in 2003.
private
if(dgChannelEntity.Items[1].ItemType==ListItemType.Footer){
((Label)dgrid.Items[1].Cells[2].FindControl("lblAddStartDate")).Text="Working";
}
}
Can u help me?
nikshuklaPosted Dec 7, 2006, 12:12 PM
On button_click event
Loop through all the items in the grid. Try to start loop from the bottom. Check for item type i.e.
if DataGrid1.Items(1).ItemType = ListItemType.Footer then and find controls in this item.cell(1) or whatever cell contains your controls(label and textbox). Once you get your controls you can do whatever you want.
VS 2005
You can get your footerrow from gridview using GridView1.FootRow and try to find your control within the row.
Hope this helps.
Regards,