Click here to Skip to main content
15,883,749 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am having dropdown inside a grid .. I bound the value. But for first row only the default value added. When i add Next row the default value is not showing. Pls provide information if u know.

Well i am binding the dropdown onrowbound ...

Regards,
SarathKumar.N
Posted
Comments
Mohd. Mukhtar 21-Dec-12 7:38am    
Please provide your code here.
rahkan 21-Dec-12 7:44am    
No way to help without seeing what the code is doing

Hi,

Bind your Dropdown as below.

C#
protected void GridView_RowDataBound(Object sender, GridViewRowEventArgs e)
{
    if(e.Row.RowType == DataControlRowType.DataRow)
    {
      DropDown ddl = (DropDown)e.Row.FindControl("DropDownID");
      ListItem li = new ListItem("Default text", "Default value");
      ddl.Items.Add(li);
      ddl.DataSource = //your data items to bind the dropdown.
      ddl.Bind();
    }

}


Hope this will help you.
 
Share this answer
 
No Probs ,, I solved byu Myself..

After Bind DropDown List I got The Method

SQL
drp.ClearSelection();
                       drp.Items.FindByText(dt.Rows[i]["ProductName"].ToString()).Selected = true;
                       drp.Items.FindByValue(dt.Rows[i]["ProductListID"].ToString());
 
Share this answer
 
No Probs ,, I solved byu Myself..

After Bind DropDown List I got The Method

SQL
drp.ClearSelection();
                       drp.Items.FindByText(dt.Rows[i]["ProductName"].ToString()).Selected = true;
                       drp.Items.FindByValue(dt.Rows[i]["ProductListID"].ToString());

Code[]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900