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


i have two grid grid1 and grid2.

grid1 has last column has dropdown.


in grid2 we have add button on clicking which we get new rows.on button click new row will be added to grid2.


now my requirement is whenever i had new row in grid2 automatically a check box should be added to dropdown in grid1
Posted
Comments
Where is the problem?
spanner21 13-Dec-13 1:31am    
Hi Tadit i am not getting idea how to str=art and from where to proceed
Inside Button Click, try to find the control of Grid1. I don't know how you are adding checkbox to DropDown, but this is the way. Once you find the control, then add that.
spanner21 13-Dec-13 2:41am    
i got the control inside dropdown using
gvRow.Cells[3].FindControl("ddlFeetx") as DropDownList


now can i add the checkbox inside dropdown ...this is my doubt as i think i cant,,but i am planning to take combobox can i add check box inside combobox
You have to think some other way. Check my answer, you will get the idea. :)

If you want to add CheckBox inside DropDownList, then you have to do it in some other way because there is no such default behaviour supported by DropDownList.

So, you should go for DropDownCheckList ASP.NET Server Control[^].

You can add this to your GridView and try.

All the best. :)
 
Share this answer
 
Try something like this..
C#
protected void btnGrid2Insert_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow gvRow in gvGrid1.Rows)
        {
            DropDownList ddl = (gvRow.Cells[5].FindControl("ddlName") as DropDownList);
            DataTable dt = getYourSource();
            ddl.DataSource = dt;
            ddl.DataTextField = "";
            ddl.DataValueField = "";
            ddl.DataBind();
        }
    }
 
Share this answer
 

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