Skip to content

How to how show and hide rows in datagrid?

deepa

Asked Jul 23, 2006, 11:17 PM EDT5 answers
Share
LinkedInX
 
Hi,
i need help...
i have a windows application, in which there a datagrid, and i have to show details in the grid in such a way, that when i click "Show Details"(which i can get as a row in the datagrid), the grid expands showingme more rows which get inserted where i clicked on show details...
Similarly, when i click 'Hide Details", the rows are not shown...

Does any one has code for this funnctionality of datagrid? plz do help me...
thanx,
Deepa

5 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Hi deepa,
     
        
               if u want the datagrid to show nothing just set its datasource to null.

              Here is the sample code,
             

    private void Execute(string qry)

    {

    OleDbConnection oconn=new OleDbConnection(Connstr);

    OleDbCommand ocomm=new OleDbCommand(Query,oconn);

    OleDbDataAdapter oadap=new OleDbDataAdapter();

    oadap.SelectCommand=ocomm;

    ds.Clear();

    oadap.Fill(ds,"tblSTU");

    }

    private void btnShow_Click(object sender, System.EventArgs e)

    {

    Query = "SELECT * FROM tblSTU";

    Execute(Query);

    dataGrid1.DataSource = ds.Tables[0];

    }

    private void btnHide_Click(object sender, System.EventArgs e)

    {

    dataGrid1.DataSource = null;

    }

     Hope this helps u.


    0
  • 0
    hey..i need it to look like this:

    plz check website :www.dohop.com, then perform some search ..u'll get recordswith hidden details..then when u click on 'Show Details" it expands

    i have datatable with all details at first, then i need to manipulate it in such a way in the datagrid which will make it look like in the website :-/
    plz check it...plz help me..its urgent...im confused 

    thanks a lot...
    Deepa
     
    0
  • 0
    I saved dohop.com in my local system and found that they r using javascript . Of u want u can also use the same method . But the values are not from database .
    Cheers,
    Raghu
    0
  • 0
    Hi Deepa ,

    i searched in net but could not find out a solution for this so i came up with my own application.

    as i couldnt post my whole appln here i can send u thru mail

    0