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.

Please let me know why dropdownlist selected item is not getting changed ?
Also all my code in Page_load is inside if (!IsPostBack).

My Code is as below.

binding gridview in the popup:-

# protected void btnSearch_Click(object sender, EventArgs e)
# {
# DataTable dtContract = new DataTable();
# dtContract = objBLTimesheet.RunQuery(query);
#
#
# gvOrders.DataSource = dtContract;
# gvOrders.DataBind();
# }

And I am binding dropdownlist inside Gridview at RowDataBound Event as below:-

1. protected void gvOrders_RowDataBound(object sender,
GridViewRowEventArgs e)
2. {
3. if (e.Row.RowType == DataControlRowType.DataRow)
4. {
5. string Ordrno = rw.Cells[0].Text;
6. string query = "select MCSRLNO,FOORD from mccommdata";
7. DataTable dtmcslorder = new DataTable();
8. dtmcslorder = objBLTimesheet.RunQuery(query);
9. if (dtmcslorder.Rows.Count > 0)
10. {
11.
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataSource = dtmcslorder;
12.
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataTextField = "MCSRLNO";
13.
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataValueField = "FOORD";
14.
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataBind();
15.
16. }
17.
18. }
19. }
 
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.

Please let me know why dropdownlist selected item is not getting changed ?
Also all my code in Page_load is inside if (!IsPostBack).

My Code is as below.

binding gridview in the popup:-

# protected void btnSearch_Click(object sender, EventArgs e)  
#         {  
# DataTable dtContract = new DataTable();  
#                 dtContract = objBLTimesheet.RunQuery(query);  
#  
#                  
#                     gvOrders.DataSource = dtContract;  
#                     gvOrders.DataBind();  
# }

And I am binding dropdownlist inside Gridview at RowDataBound Event as below:-

   1. protected void gvOrders_RowDataBound(object sender,
GridViewRowEventArgs e)  
   2.         {  
   3.             if (e.Row.RowType == DataControlRowType.DataRow)  
   4.             {  
   5.         string Ordrno = rw.Cells[0].Text;  
   6.                 string query = "select MCSRLNO,FOORD from mccommdata";  
   7.                 DataTable dtmcslorder = new DataTable();  
   8.                 dtmcslorder = objBLTimesheet.RunQuery(query);  
   9.                 if (dtmcslorder.Rows.Count > 0)  
  10.                 {  
  11.                    
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataSource = dtmcslorder;  
  12.                    
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataTextField = "MCSRLNO";  
  13.                    
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataValueField = "FOORD";  
  14.                    
((DropDownList)rw.FindControl("ddlSlnoOrder")).DataBind();  
  15.                      
  16.                 }  
  17.          
  18.          }  
  19.         }  

http://groups.google.com/group/micr...read/thread/0c9cf84f3f4949c9/0c819611a078871b
 

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,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top