hii,
i have gridview which displays cityname and Price.
i have one checkbox which is dynamically created based on number of city.
functionality:
when cityname checkbox checked respective price must be displayed based on citycode. How to achieve this please assist.
Gridview with checkbox
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
samantaRank #4,544 · 336 pointsPosted Jan 23, 2014, 8:35 PM EST
protected void chkCity_OnCheckedChanged(object sender, EventArgs e) { GridViewRow row = (GridViewRow)(((CheckBox)sender).NamingContainer); HiddenField hdCityCodeValue = (HiddenField)row.Cells[0].FindControl("hdCityCode"); HiddenField hdStandardCost = (HiddenField)row.Cells[0].FindControl("hdCostStandard"); Label objLabelPrice = (Label)row.FindControl("lblPrice"); int cityCode = Convert.ToInt32(hdCityCodeValue.Value); string standardPrice = hdStandardCost.Value; if (((CheckBox)sender).Checked == true) { objLabelPrice.Visible = true; objLblTestCityCode.Text = cityCode.ToString(); objLabelPrice.Text = "Rs. " + standardPrice; if (cityCode == -1) { (grdView.Rows[i].FindControl("chkCity") as CheckBox).Checked = false; (grdView.Rows[i].FindControl("chkCity") as CheckBox).Enabled = false; objLblTestCityCode.Text = cityCode.ToString(); objLabelPrice.Text = "Rs. " + standardPrice; ((CheckBox)sender).Enabled = true; ((CheckBox)sender).Checked = true; objLabelPrice.Visible = true; } checkcount = checkCount(); if (checkcount == count) { for (int j = 0; j < grdView.Rows.Count; j++) { if ((grdView.Rows[j].FindControl("chkCity") as CheckBox).Checked == true) { (grdView.Rows[j].FindControl("chkCity") as CheckBox).Enabled = false; (grdView.Rows[j].FindControl("chkCity") as CheckBox).Checked = false; objLabelPrice.Text = ""; } else { (grdView.Rows[j].FindControl("chkCity") as CheckBox).Checked = true } } } } else { objLabelPrice.Visible = false; (grdView.Rows[i].FindControl("chkCity") as CheckBox).Enabled = true; } }samantaRank #4,544 · 336 pointsPosted Jan 23, 2014, 8:46 PM EST
Biswa Pujarini MohapatraRank #463 · 5.4K pointsPosted Jan 23, 2014, 8:55 PM EST
samantaRank #4,544 · 336 pointsPosted Jan 23, 2014, 8:58 PM EST
BorderStyle="None"
RowStyle-HorizontalAlign="Left" GridLines="None" >
<%-- --%>
<%----%>
<%# DisplayProductPrice(((System.Data.DataRowView)Container.DataItem).Row)%>
1 short reply
Biswa Pujarini MohapatraRank #463 · 5.4K pointsPosted Jan 23, 2014, 8:25 PM EST