|
Hi All
i have a gridview
<asp:GridView ID="GridView2" runat="server" Width="100%"
AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="description" HeaderText="Description" >
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:BoundField>
<asp:BoundField DataField="Amount" HeaderText="Amount" >
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:BoundField>
<asp:TemplateField HeaderText="Month">
<ItemTemplate>
<asp:CheckBox ID="CheckBoxJan" runat="server" Text="Jan" AutoPostBack="True"
oncheckedchanged="CheckBoxJan_CheckedChanged" />
<asp:CheckBox ID="CheckBoxFeb" runat="server" Text="Feb" AutoPostBack="True"
oncheckedchanged="CheckBoxJan_CheckedChanged" />
<asp:CheckBox ID="CheckBoxMar" runat="server" Text="Mar" AutoPostBack="True"
oncheckedchanged="CheckBoxJan_CheckedChanged" />
<asp:CheckBox ID="CheckBoxApr" runat="server" Text="Apr" AutoPostBack="True"
oncheckedchanged="CheckBoxJan_CheckedChanged" />
<asp:CheckBox ID="CheckBoxMay" runat="server" Text="May" AutoPostBack="True"
oncheckedchanged="CheckBoxJan_CheckedChanged" />
<asp:CheckBox ID="CheckBoxJun" runat="server" Text="Jun" AutoPostBack="True"
oncheckedchanged="CheckBoxJan_CheckedChanged" />
<asp:CheckBox ID="CheckBoxJul" runat="server" Text="Jul" AutoPostBack="True"
oncheckedchanged="CheckBoxJan_CheckedChanged" />
<asp:CheckBox ID="CheckBoxAug" runat="server" Text="Aug" AutoPostBack="True"
oncheckedchanged="CheckBoxJan_CheckedChanged" />
<asp:CheckBox ID="CheckBoxSep" runat="server" Text="Sep" AutoPostBack="True"
oncheckedchanged="CheckBoxJan_CheckedChanged" />
<asp:CheckBox ID="CheckBoxOct" runat="server" Text="Oct" AutoPostBack="True"
oncheckedchanged="CheckBoxJan_CheckedChanged" />
<asp:CheckBox ID="CheckBoxNov" runat="server" Text="Nov" AutoPostBack="True"
oncheckedchanged="CheckBoxJan_CheckedChanged" />
<asp:CheckBox ID="CheckBoxDec" runat="server" Text="Dec" AutoPostBack="True"
oncheckedchanged="CheckBoxJan_CheckedChanged" />
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:TemplateField>
</Columns>
</asp:GridView>
and i am using checked change event for checkbox as
protected void CheckBoxJan_CheckedChanged(object sender, EventArgs e)
{
string desc = "";
Double amount = 0;
for (Int32 i = 0; i < GridView2.Rows.Count; i++)
{
double amt = 0;
CheckBox checkBox1 = (CheckBox)GridView2.Rows[i].Cells[2].FindControl("CheckBoxJan");
bool isChecked1 = checkBox1.Checked;
CheckBox checkBox2 = (CheckBox)GridView2.Rows[i].Cells[2].FindControl("CheckBoxFeb");
bool isChecked2 = checkBox2.Checked;
CheckBox checkBox3 = (CheckBox)GridView2.Rows[i].Cells[2].FindControl("CheckBoxMar");
bool isChecked3 = checkBox3.Checked;
CheckBox checkBox4 = (CheckBox)GridView2.Rows[i].Cells[2].FindControl("CheckBoxApr");
bool isChecked4 = checkBox4.Checked;
CheckBox checkBox5 = (CheckBox)GridView2.Rows[i].Cells[2].FindControl("CheckBoxMay");
bool isChecked5 = checkBox5.Checked;
CheckBox checkBox6 = (CheckBox)GridView2.Rows[i].Cells[2].FindControl("CheckBoxJun");
bool isChecked6 = checkBox6.Checked;
CheckBox checkBox7 = (CheckBox)GridView2.Rows[i].Cells[2].FindControl("CheckBoxJul");
bool isChecked7 = checkBox7.Checked;
CheckBox checkBox8 = (CheckBox)GridView2.Rows[i].Cells[2].FindControl("CheckBoxAug");
CheckBox checkBox9 = (CheckBox)GridView2.Rows[i].Cells[2].FindControl("CheckBoxSep");
bool isChecked8 = checkBox8.Checked;
CheckBox checkBox10 = (CheckBox)GridView2.Rows[i].Cells[2].FindControl("CheckBoxOct");
bool isChecked9 = checkBox9.Checked;
CheckBox checkBox11 = (CheckBox)GridView2.Rows[i].Cells[2].FindControl("CheckBoxNov");
CheckBox checkBox12 = (CheckBox)GridView2.Rows[i].Cells[2].FindControl("CheckBoxDec");
bool isChecked10 = checkBox10.Checked;
bool isChecked11 = checkBox11.Checked;
bool isChecked12 = checkBox12.Checked;
if (isChecked1 && checkBox1.Enabled==true)
{
amt = Convert.ToDouble(GridView2.Rows[i].Cells[1].Text);
amount = amount + amt;
desc = desc + "Jan" + ",";
}
if (isChecked2 && checkBox2.Enabled == true)
{
amt = Convert.ToDouble(GridView2.Rows[i].Cells[1].Text);
amount = amount + amt;
desc = desc + "Feb" + ",";
}
if (isChecked3 && checkBox3.Enabled == true)
{
amt = Convert.ToDouble(GridView2.Rows[i].Cells[1].Text);
amount = amount + amt;
desc = desc + "Mar" + ",";
}
if (isChecked4 && checkBox4.Enabled == true)
{
amt = Convert.ToDouble(GridView2.Rows[i].Cells[1].Text);
amount = amount + amt;
desc = desc + "Apr" + ",";
}
if (isChecked5 && checkBox5.Enabled == true)
{
amt = Convert.ToDouble(GridView2.Rows[i].Cells[1].Text);
amount = amount + amt;
desc = desc + "May" + ",";
}
if (isChecked6 && checkBox6.Enabled == true)
{
amt = Convert.ToDouble(GridView2.Rows[i].Cells[1].Text);
amount = amount + amt;
desc = desc + "Jun" + ",";
}
if (isChecked7 && checkBox7.Enabled == true)
{
amt = Convert.ToDouble(GridView2.Rows[i].Cells[1].Text);
amount = amount + amt;
desc = desc + "Jul" + ",";
}
if (isChecked8 && checkBox8.Enabled == true)
{
amt = Convert.ToDouble(GridView2.Rows[i].Cells[1].Text);
amount = amount + amt;
desc = desc + "Aug" + ",";
}
if (isChecked9 && checkBox9.Enabled == true)
{
amt = Convert.ToDouble(GridView2.Rows[i].Cells[1].Text);
amount = amount + amt;
desc = desc + "Sep" + ",";
}
if (isChecked10 && checkBox10.Enabled == true)
{
amt = Convert.ToDouble(GridView2.Rows[i].Cells[1].Text);
amount = amount + amt;
desc = desc + "Oct" + ",";
}
if (isChecked11 && checkBox11.Enabled == true)
{
amt = Convert.ToDouble(GridView2.Rows[i].Cells[1].Text);
amount = amount + amt;
desc = desc + "Nov" + ",";
}
if (isChecked12 && checkBox12.Enabled == true)
{
amt = Convert.ToDouble(GridView2.Rows[i].Cells[1].Text);
amount = amount + amt;
desc = desc + "Dec" + ",";
}
}
Label24.Text = amount.ToString();
Label17.Text = (Convert.ToDouble(Label23.Text) + Convert.ToDouble(Label24.Text) + Convert.ToDouble(Label27.Text)).ToString();
Label29.Text = desc;
}
so here after every checked change page is getting reloaded but i want to do this in javascript(client side)
so please help me to do this
regards
Ravi kant
|
|
|
|