Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 16, 2012 01:05 AM by Decker Dong - MSFT
Member
9 Points
55 Posts
Dec 15, 2012 09:30 AM|LINK
i have a dropdownlist in one of my Gridview cell.
i want to show the selected value in a output labe. i tried the following works but it does not work please help.
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { int newIndex = e.NewEditIndex; DropDownList ddList = (DropDownList)GridView1.Rows[newIndex].FindControl("DropDownList2"); if (ddList!=null) Message.Text = string.Format("i am {0}", ddList.SelectedItem); }
i also tried ddList.SelectedIndex and ddlList.selectedValue instead of ddList.SelectedItem but this also does not work.
Please help me
Contributor
6119 Points
1167 Posts
Dec 15, 2012 10:12 AM|LINK
you can download the dome program from given link
https://skydrive.live.com/?lc=24841#cid=2F22272220E37707&id=2F22272220E37707%21103
Program name =DropDown_in_Gridview
Dec 15, 2012 12:32 PM|LINK
this problem is solved through the following code
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { DropDownList ddl = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("DropDownList2"); string selectedvalue = ddl.SelectedValue; Message.Text = string.Format("i am {0}", ddList.SelectedItem); }
All-Star
118619 Points
18779 Posts
Dec 16, 2012 01:05 AM|LINK
Adnan dani this problem is solved through the following code
Congratulation!
Now I come here to close this issue. So if you have anything else to feedback, you can just create another new thread.
Reguards!
Adnan dani
Member
9 Points
55 Posts
Gridview+ dropdownlist
Dec 15, 2012 09:30 AM|LINK
i have a dropdownlist in one of my Gridview cell.
i want to show the selected value in a output labe. i tried the following works but it does not work please help.
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { int newIndex = e.NewEditIndex; DropDownList ddList = (DropDownList)GridView1.Rows[newIndex].FindControl("DropDownList2"); if (ddList!=null) Message.Text = string.Format("i am {0}", ddList.SelectedItem); }i also tried ddList.SelectedIndex and ddlList.selectedValue instead of ddList.SelectedItem but this also does not work.
Please help me
SohailShaikh
Contributor
6119 Points
1167 Posts
Re: Gridview+ dropdownlist
Dec 15, 2012 10:12 AM|LINK
you can download the dome program from given link
https://skydrive.live.com/?lc=24841#cid=2F22272220E37707&id=2F22272220E37707%21103
Program name =DropDown_in_Gridview
Sohail Shaikh
Adnan dani
Member
9 Points
55 Posts
Re: Gridview+ dropdownlist
Dec 15, 2012 12:32 PM|LINK
this problem is solved through the following code
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { DropDownList ddl = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("DropDownList2"); string selectedvalue = ddl.SelectedValue; Message.Text = string.Format("i am {0}", ddList.SelectedItem); }Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Gridview+ dropdownlist
Dec 16, 2012 01:05 AM|LINK
Congratulation!
Now I come here to close this issue. So if you have anything else to feedback, you can just create another new thread.
Reguards!