rachayita jaiswal

rachayita jaiswal

  • NA
  • 217
  • 106.4k

Select Gridview Row in ASP.Net

Aug 30 2013 1:00 AM
Hi, I have created a grid view and i am fetching data in this from database. Grid view and designing of controls both are in one form.
I want to fill all controls (text box n all) by clicking on grid view row.
In my grid view 5 fields are there but in design i have many controls. I have done this coding - 

protected void grdv_assets_OnSelectedIndexChanged(object sender, EventArgs e)
    {
        txt_assetcode.Visible = true;
        int rowIndex = grdv_assets.SelectedIndex;
        txt_assetupdatemode.Text = "true";

        ddl_assettype.SelectedValue = grdv_assets.SelectedRow.Cells[1].Text.Trim();
        txt_assetbrand.Text = grdv_assets.SelectedRow.Cells[2].Text.Trim();
        txt_assetmodel.Text = grdv_assets.SelectedRow.Cells[3].Text.Trim();
        ddl_assetVendor.SelectedValue = grdv_assets.SelectedRow.Cells[4].Text.Trim();        
        txt_assetPdate.Text = grdv_assets.SelectedRow.Cells[5].Text.Trim();
    }

these 5 control ' s value are coming from gridview row to the control but how to fill rest control's in my design???

If my question is not clear, let me know....

Answers (20)