Hai Friends
I m creating one sample application in my fields of my application are
Name:(Textbox),
class:(dropdown box)
add(button)
after press the add button entire details ll shown in gridview's with edit & delete.
now my problem is when choose edit means(Ex: i entered student name like 'ram' class '10th' in gridview if i m press edit the dropdown doesn't show the '10th') ll show in starting value.
i need display only selected value of dropdown where i m selected value doing edit.
Thanks & regrds
Rocky
Loading
Pankaj RawatPosted Apr 1, 2013, 3:24 AM
you can call the RowDataBound Event in Gridview and used HiddenField in Gridview.
in Design Page in your grid.
use hidden field
in code Behind.
protected void gridview1_DataBound(object sender,GridviewRowEventArgs e)
{
DataRowView gridrow=(DataRowView)e.Row.DataItem;
Dropdown ddl_Catagory=(Dropdown)e.Row.FindControl("ddlCatagory");
if(ddl_Catagory!=null)
{
/* Bind Your Dropdown from DataSource */
HiddenField hfCatagory_Name=(HiddenField)e.Row.FindControl("HFCategoryID");
string catagory_Name=hfCatagory_Name.value.ToString();
ddl_Catagory.Items.FindByText(catagory_Name).selected=True;
}
}