how to get text of dropdownlist of gridview
I have a gridview, in which i have taken dropdown explicitely and added 10 values in it. how can i get selected text of drop down when i change it runtime. selected index change is not giving output.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Raja KrishnamurthyPosted Mar 7, 2011, 7:43 AM
http://stackoverflow.com/questions/485390/why-isnt-the-selectedindexchanged-event-firing-from-a-dropdownlist-in-a-gridview
HTH.
Happy Programming!!!
Regards,
Raja
Raja KrishnamurthyPosted Mar 8, 2011, 12:29 PM
in the dropdownlist selected index changed method. try this:
GridViewRow objRow = (GridViewRow)((DropDownList)Sender).Parent.Parent; //this should get you the GridViewRow (first parent will get you the column)
Now that you have the GridViewRow you can do select the columns and so on and so forth. Again I cannot assure you results but it might be worth trying.
HTH.
Happy Programming!!!
Regards,
Raja
Mayur GujrathiPosted Mar 8, 2011, 9:42 AM
but i have another problem , now i am getting text of dropdown but as there are 5 columns i want text of every field of that row in which drop down is selected
I have tried like this
string sample=Grid1.Rows[e.Rowindex].cells[0].Tostring
e.rowindex is not coming in intellence and problem is not getting to pick row no on for which drop down is selected
Mayur GujrathiPosted Mar 8, 2011, 9:42 AM
but i have another problem , now i am getting text of dropdown but as there are 5 columns i want text of every field of that row in which drop down is selected
I have tried like this
string sample=Grid1.Rows[e.Rowindex].cells[0].Tostring
e.rowindex is not coming in intellence and problem is not getting to pick row no on for which drop down is selected
Mayur GujrathiPosted Mar 8, 2011, 9:41 AM
I have tried like this
string sample=Grid1.Rows[e.Rowindex].cells[0].Tostring
e.rowindex is not coming in intellence and problem is not getting to pick row no on for which drop down is selected
Mayur GujrathiPosted Mar 8, 2011, 9:41 AM
I have tried like this
string sample=Grid1.Rows[e.Rowindex].cells[0].Tostring
e.rowindex is not coming in intellence and problem is not getting to pick row no on for which drop down is selected
Mayur GujrathiPosted Mar 8, 2011, 1:30 AM
Mayur GujrathiPosted Mar 8, 2011, 1:28 AM
Answer you have given is right but it is giving text of every dropdownlist but i have 10 dropdown as 10 there 10 rows in gridview, correct answer is in post itself given by raja.krish
Suthish NairPosted Mar 7, 2011, 2:51 PM
Suthish NairPosted Mar 7, 2011, 6:24 AM
On GV1_SelectedIndexChanged
DropDownList tmpdll = (DropDownList) GV1.Rows[GV1.SelectedIndex].Cells[1].FindControl("ddl");
String val = tmpdll.SelectedItem.Text;
tmpdll = null;
Krishna GaradPosted Mar 7, 2011, 5:14 AM
DropDownList ddltemp=new DropDownList();
foreach(GridViewRow row in Gridview1.Rows)
{
ddltemp=(DropDownList)row.FindControl("Idofddl");
string _text=ddltemp.SelectedItem.Text.ToString();
}
}