downdownlist updation in gridview

Posted by Anishabathija under ASP.NET on 10/10/2012 | Points: 10 | Views : 785 | Status : [Member] | Replies : 1
hi ,

In my application in the gridview I have a dropdownlist displaying two options yes or no.
I added this using the
<Asp:tempalatefield>
<asp:itemlist>
<asp:dropdownlist>
<asp:ListItem>yes</asp:ListItem>
<asp:listitem>no</asp:listitem>///

and in my rowupdating event of the gridview I passed this as
string option = Convert.ToString((GrdView1.Rows[e.RowIndex].Cells[5].Controls[0]).ToString());


this code built succesfully
but everytime I run it and try to update the dropdownlist , it gets updated as Sytem.Web.Controls in the db.
please help.
any help will be appreciated. :)
my app is a three tier architecture based on the artice

http://www.dotnetfunda.com/articles/article71.aspx




Responses

Posted by: Britsouls on: 10/10/2012 [Member] Starter | Points: 25

Up
0
Down
Use this code on rowupdating event.
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
DropDownList ddl1 = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("DropDownList1");

update tablename set groupid=" + ddl1.SelectedValue + " where id.....
}
Regards,
Rupal Kothari

Anishabathija, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response