Click here to Skip to main content
15,886,091 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
What to do for drop down list instead of textbox..



txtItemDescription = (TextBox)GridView1.Rows[rowIndex].Cells[1].FindControl("ItemDescription");
Posted
Updated 22-Aug-13 1:32am
v2
Comments
CodeBlack 22-Aug-13 7:32am    
what is your exact question ?
xibit89 22-Aug-13 7:33am    
private void SetPreviousData()
{
TextBox tbobject = new TextBox();

int rowIndex = 0;

if (ViewState["CurrentTable"] != null)
{

DataTable dt = (DataTable)ViewState["CurrentTable"];

if (dt.Rows.Count > 0)
{

for (int i = 0; i < dt.Rows.Count; i++)
{

//tbobject = (TextBox)GridView1.Rows[rowIndex].Cells[0].FindControl("RowNumber");
//tbobject.Text = dt.Rows[i]["RowNumber"].ToString();

DropDownList itmDesc = (DropDownList)GridView1.Rows[rowIndex].Cells[1].FindControl("ItemDescription");
itmDesc.Text = dt.Rows[i]["ItemDescription"].ToString();

rowIndex++;

}

}

}
CodeBlack 22-Aug-13 7:36am    
now what is your question ? what you want to do and where are you getting error ? and what is the error ?
xibit89 22-Aug-13 8:14am    
thank you. its is done. I was not declaring dropdownlist in page load..
Nandakishore G N 22-Aug-13 8:12am    
no you cant get the rowindex of the gridview based on the index of your viewstate or datatable.
According to your question, You want to fetch the value of dropdownlist selecteditem/value right?
use gridview rowcommand or rowdatabound to fetch its values.

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