Thulasiram pakala

Thulasiram pakala

  • 900
  • 872
  • 116.6k

Rebind dropdowncheckbox list multiple district values

Dec 28 2016 4:45 AM
 hi, 
      in data base district id s splt and store the values like 1,2 like that now what i am doing remove (, ) rebind to dropdown check boxex to related district help 
 
 
 
aspx
 
<tr>
<td>
District :
</td>
<asp:TextBox ID="txtdistrict" Text="Select District" runat="server" CssClass="txtbox"
Height="20px" Width="163px"></asp:TextBox>
<asp:Panel ID="PnlDistrict" runat="server" ScrollBars="Auto" Height="20%" CssClass="PnlDesign">
<asp:CheckBoxList ID="chldistrict" runat="server">
</asp:CheckBoxList>
</asp:Panel>
<cc1:popupcontrolextender ID="PceSelectCustomer" runat="server" TargetControlID="txtdistrict"
PopupControlID="PnlDistrict" Position="Bottom">
</cc1:popupcontrolextender>
</td>
 
 
 
try
{
// ddldistrict.Items.Clear();
SqlCommand cmddt=new SqlCommand("select * from WeatherStations where StationID=1",con);
// DataTable dt = new DataTable();
con.Open();
cmddt.CommandType = CommandType.Text;
SqlDataReader dr = cmddt.ExecuteReader();
while (dr.Read())
{
PopulateCheckboxlist(dr["districtID"].ToString(), chldistrict);
}
private void PopulateCheckboxlist(string value, CheckBoxList chl)
{
if (!string.IsNullOrEmpty(value))
{
string[] values_array = value.Split(',');
foreach (string s in values_array)
{
if (!string.IsNullOrEmpty(s))
{
if (s.Split(',').Length > 0)
{
chldistrict.Items.FindByValue(s.Trim());
}
}
}
}
 

Answers (1)