strSQL = "SELECT * FROM User_Reg WHERE User_ID='" + UserId + "'"; DataTable dataTablerepeaterUserList = null; dataTablerepeaterUserList =objSqlDbComm.ExecuteDatasetQuery(strSQL).Tables[0];
foreach (DataRow dr in dataTablerepeaterUserList.Rows) { ddlTitle.SelectedItem.Text = dr["Title"].ToString(); }
<asp:DropDownList ID="ddlTitle" runat="server" CssClass="csstextbox" > <asp:ListItem>Mr.</asp:ListItem> <asp:ListItem>Mrs.</asp:ListItem> <asp:ListItem>Miss.</asp:ListItem> <asp:ListItem>Dr.</asp:ListItem> </asp:DropDownList>
if suppose dr["Title"]=Dr. then it is overwrite Mr. with Dr. and got result like. | Dr. | | Mrs. | | Miss.| | Dr. |
string s = dr["Title"].ToString(); ddlTitle.SelectedText = s;
ddlTitle.SelectedValue = dr["Title"].ToString(); change this line also <asp:dropdownlist id="ddlTitle" runat="server" cssclass="csstextbox" xmlns:asp="#unknown"> <asp:listitem text="Mr." value="Mr."></asp:listitem> <asp:listitem text="Mrs." value="Mrs."></asp:listitem> <asp:listitem text="Miss." value="Miss.">Miss.</asp:listitem> <asp:listitem text="Dr." value="Dr.">Dr.</asp:listitem> </asp:dropdownlist>
ddlTitle.SelectedItem = dr["Title"].ToString();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)