TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
krishna angirekula
NA
68
29.8k
2dropdown list filling in the grid view
May 21 2013 2:20 AM
protected void btnadd_Click(object sender, EventArgs e)
{
int rowIndex = 0;
string selectquery = "select visitorid,VisitorType from VisitorDetails Order By VisitorType";
dt = SqlHelper.Instance.GetTableByQuery(selectquery);
string selectquery1 = "select Id,ArtistsName from MehndiPortraitDetails Order By ArtistsName";
dt1 = SqlHelper.Instance.GetTableByQuery(selectquery1);
if (ViewState["CurrentTable"] != null)
{
DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
DataRow drCurrentRow = null;
if (dtCurrentTable.Rows.Count > 0)
{
for (int i = 1; i <= dtCurrentTable.Rows.Count; i++)
{
DropDownList ddlmehndi =
(DropDownList)Gridmehndi.Rows[rowIndex].Cells[0].FindControl("ddlmehndi");
DropDownList ddlArtist =
(DropDownList)Gridmehndi.Rows[rowIndex].Cells[1].FindControl("ddlArtist");
drCurrentRow = dtCurrentTable.NewRow();
TextBox Texttotalamount =
(TextBox)Gridmehndi.Rows[rowIndex].Cells[2].FindControl("txtamount");
dtCurrentTable.Rows[i - 1]["Selected List"] = ddlmehndi.SelectedValue;
dtCurrentTable.Rows[i - 1]["Name of the Artist"] = ddlArtist.SelectedValue;
dtCurrentTable.Rows[i - 1]["Amount Paid"] = Texttotalamount.Text;
rowIndex++;
}
dtCurrentTable.Rows.Add(drCurrentRow);
ViewState["CurrentTable"] = dtCurrentTable;
Gridmehndi.DataSource = dtCurrentTable;
Gridmehndi.DataBind();
}
}
else
{
Response.Write("ViewState is null");
}
foreach (GridViewRow gvrow in Gridmehndi.Rows)
{
DropDownList ddlmehndi = (DropDownList)gvrow.FindControl("ddlmehndi");
ddlmehndi.DataTextField = " VisitorType";
ddlmehndi.DataValueField = "Visitorid";
ddlmehndi.DataSource = dt;
ddlmehndi.DataBind();
}
foreach (GridViewRow gvrow1 in Gridmehndi.Rows)
{
DropDownList ddlArtist = (DropDownList)gvrow1.FindControl("ddlArtist");
ddlArtist.DataTextField = "ArtistsName";
ddlArtist.DataValueField = "id";
ddlArtist.DataSource = dt1;
ddlArtist.DataBind();
}
SetPreviousData();
}
Reply
Answers (
0
)
to display list of users to chat and message
TextboxValidation