ASP.NET - GridView - How to programmatically add and read new controls to the cell? -
Here's the setup: I am using the program to query my GRDUL SQL query from LINQ. Then I enter the edit mode and want to change some standard textbox controls from the dropdown list like this:
'Excerpt from GridView1_RowEditing
dim ddlist1 new dropdown list slow reset 1 = item select items Mydb.Items 1 Lkkol 10 ddlist1.DataSource = res1 ddlist1.DataBind () GridView1.Rows.Item (0) Ksel (1) .Controls.Add (ddlist1)
At this moment I have the Gridview standard text box control and the new DD list control (column 1). The problem is - I can read values from DDLI in RWUpdating method. It seems that the DD list control is not in Gridview 1. Ro ITEM (0) .Cell (1). Collection of Controls The Row-updating method only looks at the standard text box control and it can value the value. Welcome any suggestions I just do not understand something here: (Use
TemplateField , And then you can find out using your dropdown FindControl ...
& lt; ASP: GridView id = "GridView1" runat = "server" & gt; & lt; column & gt; & Lt; ASP: TemplateField & gt; & gt; ItemTemplate & gt; & lt; ASP: Text Box ID = "TextBox1" runat = "Server" & gt; & lt; / ASP: Text Box & gt; & lt; / ItemTemplate & gt; & lt; EditItemTemplate & gt; & lt; ASP: DropDownList ID = "DropDownList1" runat = "server">
sAFE sub GridView1_RowUpdating (ByVal as the object, as ByVal e System.Web.UI.WebControls.GridViewUpdateEventArgs) handles GridView1.RowUpdating dim DDL = CTYPE (GridView1 .Rows (e.RowIndex) .Cells (1) .FindControl ( "DropDownList1"), the dropdown list) end sub
Comments
Post a Comment