views:

51

answers:

1

I have One grid say Grid 1 in which there are some columns. There is one view image button, one delete image button and one column which says that color column is Red or Blue.

If color column is Red the deleted button is hidden else its shown (Based on user given rights to delete a column or not).

Now a user clicks a view button for Red Color Column. If this condition is satisfied, then i want that delete icon should not be present in Grid 2.

Grid 2 has 2 columns. One is deleted image button and one is file name (which is uploaded via upload control).

So If in Grid One "View Image Button" is clicked for "Red" Column i should be able to hide the delete button from Grid 2.

I have tried by writing code in Item command but i am not able to access control of grid2. is this the correct way? Or else suggest me some correct way.

Please Make sure that code is compatible with VS 2003.

let me know if more inputs are needed.

Thanks

A: 

grid2.Rows[<index>].Cells[<index>].FindControl("") should work, provided the grid is bound with data.

EDIT: In user control code-behind, you can expose the grid as:

public DataGrid Grid
{
   get { return this.<gridID>; }
}

and then in the page code-behind, access the grid using the following:

public class SomePage : Page
{
   .. OnInit(..)
   {
       this.uc1.Grid.<props/methods>
   }
}

Whatever you need to do. You can even attach to the grid's events too.

Brian
where i am suppose to write this code? In Grid 1 Item Command or in Grid 2 Item command or some-where else? Plus How could you access anyone Grid's control if they are in 2 different user control pages? Grid are on same .aspx page btw.>>>
Romil Nagrani
At the point you want to access grid 2's objects... which by your post seems to be in grid1 itemcommand event. I didn't see anything in the post about a user control... if they are in separate user controls on the same page, you can have a public property in the user control (public property Grid as GridView) and then refer to the user control you need to access as in uc1.Grid.Rows[<index>].Cells[<index>].FindControl("")
Brian
i am writing your code but i am facing error saying rows is not a member of DataGrid...I guess it is DataGrid and not Grid View
Romil Nagrani
Your post says gridview?? Whatever the object is, make it that type. Also, GridView gives you a lot more out of the box if you can use it; it's a part of .NET 2.0 and greater...
Brian
Grid-view was written by mistake. Its DataGrid. I am using VS 2003 so can't use GridView
Romil Nagrani
Plus how to make its type? Will be your code accessible when i make its type?
Romil Nagrani
? Not sure what you mean about making its type?. I'll update the code sample above.
Brian