citizenzen
Programmer
I have a detailsview which is based on the selection of mastergrid. The detailsview has templatefields for editing and I included textboxes, radiobuttonlists, dropdownlists, etc. When the user chooses to edit, I need to retrieve the sql values so they can see what they previously chose. However, I am unable to successfully bind anything but the textboxes and labels. How do i bind and pull the values for my drop-downs and radiobutton lists?
The following is a sample of my bindDetails subprocedure, i tried binding just a radiobuttonlist and a dropdownlist, but I get many errors. the dropdownlist should feature not only the user's previous selection, but new options from the database.
Please advise.
Code:
SqlCommand detcomm = new SqlCommand("select * from view_shwAllMusic WHERE ID=@ID", detconn);
DataTable mdt = new DataTable();
try
{
foreach (GridViewRow abc in musicGrid.Rows)
{
CheckBox bCheck = (CheckBox)abc.FindControl("selectMusic");
if (bCheck != null && bCheck.Checked)
{
int Req = Convert.ToInt32(musicGrid.DataKeys[abc.RowIndex].Value);
detcomm.Parameters.AddWithValue("@ID", Req);
SqlDataAdapter joy = new SqlDataAdapter(detcomm);
joy.Fill(mdt);
//BIND TEMPLATE CONTROLS
RadioButtonList myvideo = (RadioButtonList)musicDetailsGV.FindControl("videoTypeRadioList");
DropDownList myformat = (DropDownList)musicDetailsGV.FindControl("formatDropList");
//new datasource for format, to pull new records
myvideo.DataSource = mdt;
myvideo.SelectedValue = "Videotype";
myvideo.DataValueField = "VideoType";
myvideo.DataBind();
}
musicDetailsGV.AutoGenerateRows = false;
musicDetailsGV.DataSource = mdt;
musicDetailsGV.DataBind();
}