Assigning the SelectedValue of Dropdownlist within Gridview to a datatable field
-
for (int i = 0; i < dtCurrentTable.Rows.Count; i++)
{
//extract the TextBox values
DropDownList ddlFrequency = (DropDownList)mdlpopupGrid.Rows[rowIndex].Cells[4].FindControl("ddlFrequency");
drCurrentRow = dtCurrentTable.NewRow();
dtCurrentTable.Rows[i]["Start_Salary"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[1].FindControl("txtStartSalary")).Text;
dtCurrentTable.Rows[i]["End_Salary"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[2].FindControl("txtEndSalary")).Text;
dtCurrentTable.Rows[i]["Increament"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[3].FindControl("txtIncreament")).Text;
dtCurrentTable.Rows[i]["Frequency"] = ddlFrequency.SelectedValue.ToString();
rowIndex++;
}This is my Code in Which I assigns the Values of all textboxes & Dropdownlist within mdlpopupGrid into a Datatable... But the Problem is I dont get the Selectedvalue of Dropdownlist to my Datatable dtCurrentTable
-
for (int i = 0; i < dtCurrentTable.Rows.Count; i++)
{
//extract the TextBox values
DropDownList ddlFrequency = (DropDownList)mdlpopupGrid.Rows[rowIndex].Cells[4].FindControl("ddlFrequency");
drCurrentRow = dtCurrentTable.NewRow();
dtCurrentTable.Rows[i]["Start_Salary"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[1].FindControl("txtStartSalary")).Text;
dtCurrentTable.Rows[i]["End_Salary"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[2].FindControl("txtEndSalary")).Text;
dtCurrentTable.Rows[i]["Increament"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[3].FindControl("txtIncreament")).Text;
dtCurrentTable.Rows[i]["Frequency"] = ddlFrequency.SelectedValue.ToString();
rowIndex++;
}This is my Code in Which I assigns the Values of all textboxes & Dropdownlist within mdlpopupGrid into a Datatable... But the Problem is I dont get the Selectedvalue of Dropdownlist to my Datatable dtCurrentTable
sheringkapoting wrote:
But the Problem is I dont get the Selectedvalue of Dropdownlist
Are you getting the value of Textbox of each Cells??
Sanjay Kunjam ------------------------------------------------------------------ "Computers are useless. They can only give answers" - Pablo Picasso ------------------------------------------------------------------
-
sheringkapoting wrote:
But the Problem is I dont get the Selectedvalue of Dropdownlist
Are you getting the value of Textbox of each Cells??
Sanjay Kunjam ------------------------------------------------------------------ "Computers are useless. They can only give answers" - Pablo Picasso ------------------------------------------------------------------
Yes I Get the Values of Text Boxes, The problem lies only in Dropdown List....
-
for (int i = 0; i < dtCurrentTable.Rows.Count; i++)
{
//extract the TextBox values
DropDownList ddlFrequency = (DropDownList)mdlpopupGrid.Rows[rowIndex].Cells[4].FindControl("ddlFrequency");
drCurrentRow = dtCurrentTable.NewRow();
dtCurrentTable.Rows[i]["Start_Salary"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[1].FindControl("txtStartSalary")).Text;
dtCurrentTable.Rows[i]["End_Salary"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[2].FindControl("txtEndSalary")).Text;
dtCurrentTable.Rows[i]["Increament"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[3].FindControl("txtIncreament")).Text;
dtCurrentTable.Rows[i]["Frequency"] = ddlFrequency.SelectedValue.ToString();
rowIndex++;
}This is my Code in Which I assigns the Values of all textboxes & Dropdownlist within mdlpopupGrid into a Datatable... But the Problem is I dont get the Selectedvalue of Dropdownlist to my Datatable dtCurrentTable
change the name of
ddlFrequency
toddlFrequencyFC
or anything..just rename it.. see the difference.. Thanks