You must Sign In to post a response.
  • Category: .NET

    In grid view 3rd column is combobox and binding data to this column only and when i run

    In grid view 3rd column is combobox
    and binding data to this column only and
    when i run application it take double click to
    dropdown the list in gridview so how to set for
    single click , it should be dropdown for single click .
  • #693615
    Hai Rajanikant,
    Your question is not clear. After reading the question what I understood is that you have a dropdown list in your GridView and the dropdown list is in the 3rd column of the GridView. Now you want to fill the Dropdown data in the run mode when you will click on the Dropdown, the data will get filled.
    If this is the situation, then you need to write the event handler for the Dropdonw lists which should be executed on the click event. Attach the click event for the Drop-down lists and then write the code on it.
    Your total code will be something like the below:
    1. Place a dropdownlist as the Item in the Template column of the GridView and then write the OnRowDataBound event for the GridView as:

    void GridView1_RowDataBound(Object sender, GridViewRowEventArgs e)
    {

    if(e.Row.RowType == DataControlRowType.DataRow)
    {
    DropdownList ddl = (DropDownList)e.Row.Cell[2].FindCopntrol("ddlMyDropDownList");
    if(ddl != null)
    ddl.Attributes.Add("onclick", "JavaScript: FillDropDownList();");
    }
    }

    Now you need to write the JavaScript function which will fill the drop-down lists when it will be clicked.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #693616
    DataBinding will be done while form load event after this in grid view that 3rd column combobox column will drop down currently if i click twice time so requirement is it should be drop down for single click

  • #693617
    using c# code for window application

  • #693647
    You can refer this sample code for adding data in drop down list


    void CustomersGridView_RowDataBound(Object sender, GridViewRowEventArgs e)
    {

    if(e.Row.RowType == DataControlRowType.DataRow)
    {
    label lbl = (label) e.Row.FindControl("lblHidden");
    DropDownList ddl = (label) e.Row.FindControl("ddlID");

    if(lbl.Text =="A")
    {
    ddl.Items.Clear();
    ddl.Items.Add("B");
    ddl.Items.Add("C")
    }
    Else if(lbl.Text =="B")
    {
    ddl.Items.Clear();
    ddl.Items.Add("C")
    }
    }

    }

    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #693660
    In pop up grid view i selected some items by clicking 1st column checkbox column and fecth those selected data to form1's gridview and i want to know agian if i click pop up in that pop up gridview those items should be selected using c# code for window application


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.