I have a gv with a dropwond list inside teh cells fro binding and selecting data. I am using the rowdataBound event Rowtype to check the value of the cell but it is not working. Also I cannot reference the columns that I have hidden using this rowdatabound
(not sure why?)
e.g.
Protected Sub gv_RowDataBound(ByVal e....)
If e.Row.Rowtype = DataControlRowType.DataRow Then
labelDebug.text = e.Row.Cells(3).Text 'Row has a dropdownlist and cannot refrence the value??
Tried you suggestion - No Go! see below - Basically for gridview in rowdatabound event I unhide the columns and try to display them with textbox then hide them again. The textbox does not show the items using the suggestion and sample below.
If e.Row.RowType = DataControlRowType.DataRow Then
Why not use hiddent field together with the ddl and bind the value property
Protected Sub gv_RowDataBound(ByVal e....)
If e.Row.Rowtype = DataControlRowType.DataRow Then
Dim hf as hiddenfield = ctype(e.row.findcontrol("hiddenfield1"), hiddenfield)
dim myvalue as string = hf.value
End If
End Sub
Thx your reply - I did try to hide the column in rowdatabound event e.column(x) but this throws off the edit/udpate start getting errors on update of row. Will try your GridView1.Columns(0).Visible = True and get back.
Just want to update this thread that I have all this working. I was able to edit the ASPX file and modify the update statement which was causing an error and one other GV section that lists the control I setup for the cell displays. Also cells that are set
as visible=false cannot be referenced. but I was able to work around this by using other table cells that were not hidden to draw some of the data for other conditions. It took a little while but I figured it out and how it can be done.
Marked as answer by gogginl on Nov 27, 2012 04:27 PM
gogginl
Member
79 Points
261 Posts
Gridview - When dropdown control is used inside a cell and bound to data - How do I refrence the ...
Nov 09, 2012 05:44 PM|LINK
I have a gv with a dropwond list inside teh cells fro binding and selecting data. I am using the rowdataBound event Rowtype to check the value of the cell but it is not working. Also I cannot reference the columns that I have hidden using this rowdatabound (not sure why?)
e.g.
Protected Sub gv_RowDataBound(ByVal e....)
If e.Row.Rowtype = DataControlRowType.DataRow Then
labelDebug.text = e.Row.Cells(3).Text 'Row has a dropdownlist and cannot refrence the value??
End If
End Sub
clevesteve
Participant
1405 Points
406 Posts
Re: Gridview - When dropdown control is used inside a cell and bound to data - How do I refrence ...
Nov 09, 2012 06:07 PM|LINK
I think I remember accessing hidden columns by making them visible, getting the data, then making them invisible again within the function.
I think to troubleshoot your other issue, we'll probably have to see your GridView code
paindaasp
Star
12092 Points
2035 Posts
Re: Gridview - When dropdown control is used inside a cell and bound to data - How do I refrence ...
Nov 09, 2012 06:09 PM|LINK
Is the DropDownList in a TemplateField? If so, try something like:
Dim labelDebug As String = DirectCast(e.row.FindControl("myDDL"), DropDownList).SelectedItemThis assumes the DDL is named myDDL.
gogginl
Member
79 Points
261 Posts
Re: Gridview - When dropdown control is used inside a cell and bound to data - How do I refrence ...
Nov 09, 2012 06:24 PM|LINK
The gridview is not the problem - its getting the row cells (columns). The hidden columns cannot be referenced.
gogginl
Member
79 Points
261 Posts
Re: Gridview - When dropdown control is used inside a cell and bound to data - How do I refrence ...
Nov 09, 2012 06:24 PM|LINK
Hmmm that sound like it could be the trick will try and get back.
gogginl
Member
79 Points
261 Posts
Re: Gridview - When dropdown control is used inside a cell and bound to data - How do I refrence ...
Nov 09, 2012 07:15 PM|LINK
Tried you suggestion - No Go! see below - Basically for gridview in rowdatabound event I unhide the columns and try to display them with textbox then hide them again. The textbox does not show the items using the suggestion and sample below.
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Cells(0).Visible = True
e.Row.Cells(2).Visible = True
e.Row.Cells(3).Visible = True
labelDebug.Text = "R0=" + e.Row.Cells(0).Text + ", R1=" + e.Row.Cells(1).Text + ", R2=" + e.Row.Cells(2).Text + ", R3=" + e.Row.Cells(3).Text
e.Row.Cells(0).Visible = False
e.Row.Cells(2).Visible = False
e.Row.Cells(3).Visible = False
End If
clevesteve
Participant
1405 Points
406 Posts
Re: Gridview - When dropdown control is used inside a cell and bound to data - How do I refrence ...
Nov 09, 2012 08:16 PM|LINK
I think you would want to set the columns to visible, not the specific cells...
GridView1.Columns(0).Visible = True
...
labelDebug.Text = "R0=" + e.Row.Cells(0).Text + ", R1=" + e.Row.Cells(1).Text + ", R2=" + e.Row.Cells(2).Text + ", R3=" + e.Row.Cells(3).Text
...
GridView1.Columns(0).Visible = False
I'm not sure it will work, but I meant to show the columns and not the specific cells.
oned_gk
All-Star
31804 Points
6502 Posts
Re: Gridview - When dropdown control is used inside a cell and bound to data - How do I refrence ...
Nov 10, 2012 12:40 AM|LINK
Why not use hiddent field together with the ddl and bind the value property
Protected Sub gv_RowDataBound(ByVal e....) If e.Row.Rowtype = DataControlRowType.DataRow Then Dim hf as hiddenfield = ctype(e.row.findcontrol("hiddenfield1"), hiddenfield) dim myvalue as string = hf.value End If End Subgogginl
Member
79 Points
261 Posts
Re: Gridview - When dropdown control is used inside a cell and bound to data - How do I refrence ...
Nov 12, 2012 01:04 PM|LINK
Thx your reply - I did try to hide the column in rowdatabound event e.column(x) but this throws off the edit/udpate start getting errors on update of row. Will try your GridView1.Columns(0).Visible = True and get back.
gogginl
Member
79 Points
261 Posts
Re: Gridview - When dropdown control is used inside a cell and bound to data - How do I refrence ...
Nov 27, 2012 04:27 PM|LINK
Just want to update this thread that I have all this working. I was able to edit the ASPX file and modify the update statement which was causing an error and one other GV section that lists the control I setup for the cell displays. Also cells that are set as visible=false cannot be referenced. but I was able to work around this by using other table cells that were not hidden to draw some of the data for other conditions. It took a little while but I figured it out and how it can be done.