Getting value of a label after clicking on delete button in Gridvew
-
Hi all, I would like to get the value of a label from the same row after clicking the delete button. I converted the delete button into a template field and tried the following code Dim a As String = "" a = CType(GridView1.FindControl("label1"), Label).Text It gives me an error saying that object reference not found, and use the NEW keyword to declare a new object instance. I tried declaring NEW on string but gives me an error. What should I do? Best Regards, Aaron Neo
-
Hi all, I would like to get the value of a label from the same row after clicking the delete button. I converted the delete button into a template field and tried the following code Dim a As String = "" a = CType(GridView1.FindControl("label1"), Label).Text It gives me an error saying that object reference not found, and use the NEW keyword to declare a new object instance. I tried declaring NEW on string but gives me an error. What should I do? Best Regards, Aaron Neo
Hi Where did you put that code ?? If it is RowCommand Event of Gridview, you should set command name for the button. Try this... if (e.CommandName == "Insert") { Label lbl = (Label) e.FindControl('Label1'); String StrLabel = lbl.Text.ToString(); }
Harini
-
Hi Where did you put that code ?? If it is RowCommand Event of Gridview, you should set command name for the button. Try this... if (e.CommandName == "Insert") { Label lbl = (Label) e.FindControl('Label1'); String StrLabel = lbl.Text.ToString(); }
Harini
Hi, Thank you so much for your reply. I tried your coding but it can't work. "Label is a type and cannot be used as an expression" I have converted the button into a template field. I have placed the codings in the button click event: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Best Regards, Aaron