insert a image button in asp.net grid
-
I have a grid. The bind the grid with the data from a dataset. I then add a column. I have to insert an image button in this column of the grid. when i click this image it should open another window. I want to know how can i insert an image into each row of the column and how to add an OnClick event to it. I am using the InitializeRow event but i am unable to insert an image and on click handler to it. Please send me your suggestions.
-
I have a grid. The bind the grid with the data from a dataset. I then add a column. I have to insert an image button in this column of the grid. when i click this image it should open another window. I want to know how can i insert an image into each row of the column and how to add an OnClick event to it. I am using the InitializeRow event but i am unable to insert an image and on click handler to it. Please send me your suggestions.
just add a template column, and create an imagebutton in ItemTemplate. then, use ItemDataBound Event: protected void datagrid_ItemDataBound(object sender, DataGridItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem) { ImageButton imgBtn = (ImageButton)e.Item.FindControl("ImageButton1"); //do whatever you want } } Was it a cat I saw?
-
just add a template column, and create an imagebutton in ItemTemplate. then, use ItemDataBound Event: protected void datagrid_ItemDataBound(object sender, DataGridItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem) { ImageButton imgBtn = (ImageButton)e.Item.FindControl("ImageButton1"); //do whatever you want } } Was it a cat I saw?
-
I am using an infragistics grid and i am unable to find the datagrideventargs. If i create a template column and then if i bind the grid with a dataset. Will the column be overwritten by the columns in the dataset. what is a cat?
Sorry, I don't know what "infragistics grid" is. No, to bind a dataset to a datagrid will never overwrite the existing columns of the datagrid. If you set the property "AutoGenerateColumns" to false, no columns will be created when you execute "DataBind()". ---------------------------------- Was it a cat I saw?