citizenzen
Programmer
Hello.
I have a detailsview where I placed textboxes, radiobuttonlists, and dropdownlists. I am able to successfully show the database values for the textboxes, but how do i do the same for radiobuttonlists and dropdownbuttonlists? Both lists shold show the values entered from the database as the initial selection, but I also want to show new selections within the dropdown. Currently, my users have reselect everything.
Here's an example of what I have done:
CODE BEHIND for DetailsView:
I have a detailsview where I placed textboxes, radiobuttonlists, and dropdownlists. I am able to successfully show the database values for the textboxes, but how do i do the same for radiobuttonlists and dropdownbuttonlists? Both lists shold show the values entered from the database as the initial selection, but I also want to show new selections within the dropdown. Currently, my users have reselect everything.
Here's an example of what I have done:
Code:
<asp:TemplateField HeaderText="Master/Dub" ConvertEmptyStringToNull="False">
<HeaderStyle Font-Bold="True" /> <EditItemTemplate>
<asp:Label ID="videotypelbl" runat="server" Text='<%#Bind("VideoType")%>'></asp:Label><br />
<asp:RadioButtonList ID="videoTypeRadioList" runat="server" Font-Size="11px" RepeatDirection="Horizontal">
<asp:ListItem Value="0">Master</asp:ListItem>
<asp:ListItem Value="1">Dub</asp:ListItem>
</asp:RadioButtonList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="orgvideotypelbl" runat="server" Text='<%#Bind("VideoType")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
CODE BEHIND for DetailsView:
Code:
private void bindMusicDetails()
{
string showdet = ConfigurationManager.ConnectionStrings["UpdInventory"].ConnectionString;
SqlConnection detconn = new SqlConnection(showdet);
SqlCommand detcomm = new SqlCommand("select * from view_showAudio 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);
}
musicDetailsGV.AutoGenerateRows = false;
musicDetailsGV.DataSource = mdt;
musicDetailsGV.DataBind();
}
}
catch (SqlException risk)
{
detErrors.Text = "Error binding details<br>" + risk;
}
}