dropdownlist selected Index remains zero.

H

Harsha

Hi,

I have a ModalPopupExtender in my page. And In popup I am showing a
gridview. Inside Gridview a dropdownlist is there.

In pop there is a submitt button. But problem is in dropdownlist selected
index remains zero irespective of my selection. Even after I select
second,third or fourth Item ti will show first item of the dropdown as the
selected Item. Please help.

Also, all my code

Please let me know why dropdownlist selected item is not getting changed ?
My Code is as below.

Code to bind gridview in popup window :-
1. protected void btnSearch_Click(object sender, EventArgs e)
2. {
3. DataTable dtContract = new DataTable();
4. dtContract = objBLTimesheet.RunQuery(query);
5.
6.
7. gvOrders.DataSource = dtContract;
8. gvOrders.DataBind();
9. }

And I am binding dropdownlist inside Gridview at RowDataBound Event as below:-
# protected void gvOrders_RowDataBound(object sender, GridViewRowEventArgs
e)
# {
# if (e.Row.RowType == DataControlRowType.DataRow)
# {
# string Ordrno = rw.Cells[0].Text;
# string query = "select MCSRLNO,FOORD from mccommdata";
# DataTable dtmcslorder = new DataTable();
# dtmcslorder = objBLTimesheet.RunQuery(query);
# if (dtmcslorder.Rows.Count > 0)
# {
#
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataSource = dtmcslorder;
#
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataTextField = "MCSRLNO";
#
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataValueField = "FOORD";
#
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataBind();
#
# }
#
# }
 
G

Guest

Hi,

I have a ModalPopupExtender in my page. And In popup I am showing a
gridview. Inside Gridview a dropdownlist is there.

In pop there is a submitt button. But problem is in dropdownlist selected
index remains zero irespective of my selection. Even after I select
second,third or fourth Item ti will show first item of the dropdown as the
selected Item. Please help.

Also, all my code

Please let me know why dropdownlist selected item is not getting changed ?
My Code is as below.

Code to bind gridview in popup window :-
   1. protected void btnSearch_Click(object sender, EventArgs e)  
   2.         {  
   3. DataTable dtContract = new DataTable();  
   4.                 dtContract = objBLTimesheet.RunQuery(query);  
   5.  
   6.                  
   7.                     gvOrders.DataSource = dtContract;  
   8.                     gvOrders.DataBind();  
   9. }  

And I am binding dropdownlist inside Gridview at RowDataBound Event as below:-
# protected void gvOrders_RowDataBound(object sender, GridViewRowEventArgs
e)  
#         {  
#             if (e.Row.RowType == DataControlRowType.DataRow)  
#             {  
#         string Ordrno = rw.Cells[0].Text;  
#                 string query = "select MCSRLNO,FOORD from mccommdata";  
#                 DataTable dtmcslorder = new DataTable();  
#                 dtmcslorder = objBLTimesheet.RunQuery(query);  
#                 if (dtmcslorder.Rows.Count > 0)  
#                 {  
#                    
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataSource = dtmcslorder;  
#                    
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataTextField = "MCSRLNO";  
#                    
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataValueField = "FOORD";  
#                    
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataBind();  
#                      
#                 }  
#          
#          }  

You code doesn't show where you do the submit. It might be that you
rebind gvOrders again...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top