I have a gridview in which I create dynamically bound fields. My first column in Gridview is an image, while the other three columns are dynamically generated.
When I click on the image in my first column, then I should consider the second column. How can I get it? Apart from this, I'm unable to disable the event in clicking on the image button.
ASPX code:
& lt; Table & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; Div style = "overflow-y: scroll; max-height: 97.5 vh" & gt; & Lt; Asp: gridview id = "gvcustomers" runat = "server" autoogenerate column = "false" CssClass = "grid" OnRowCommand = "OnRowCommand" width = "500px"> & Lt; Columns & gt; & Lt; ASP: TemplateField & gt; & Lt; ItemTemplate & gt; & Lt; Img alt = "" id = "edit image" style = "cursor: indicator" height = "24" width = "24" src = "image / plus.png" /> & Lt; / ItemTemplate & gt; & Lt; / ASP: TemplateField & gt; & Lt; / Column & gt; & Lt; / ASP: GridView & gt; & Lt; / Div & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt;
CS file
// This 4 column displays gridfoshed with zero Page_Old (object sender, EventArgues E) {DataTableDT = / / Calling SP and displaying results; // 3 column: ID, NAME, TITLE foreach (DataColumn colon in dt.Column) {Boundfield bfield = new Boundfield (); Bfield.DataField = col.ColumnName; Bfield.HeaderText = col.ColumnName; GvCustomers.Columns.Add (bfield); } GvCustomers.DataSource = dt; GvCustomers.DataBind (); } Protected Zero Onro Commands (Object Sender, Grid Week CommendAnt.RGS E) {// I think I need to write here to click on IMet button}
Use
& asp: ImageButton runat = "server" id = "imgBtn" CommandArgument = '& lt;% # Eval ("ValueContainer ")%> ImageUrl =" ~ / images / plus.png "/>
on cs:
Protected Zero OnRowCommand (object Sender, GridViewCommandEventArgs e) I think, write here to write image here Var value = e.CommandArgument;}
Pre-render to click on the image button:
Protected void projection (Object Sender, EventAgps E ) {Foreach (Gridviewer Row in GVC Client.) {Var imgBtn = (ImageButton) row.FindControl ("imgBtn"); ImgBtn.CommandArgument = row.Cells [1] .text;}}
No comments:
Post a Comment