Hi I have two radio buttons in my from
a)Campaign ID Range b)Manual Entry
When i click on on Campaign ID Range i will be able to add range in the following text box.
other radio button Manual Entry will be disabled at that time. But when i select Manual Entry and add data in it it works fine but after pressing the submit button so that data would be show in the grid.it won't but it gives error at
for (int k = Convert.ToInt32(se[j]); k <= Convert.ToInt32(sf[j]); k++)
error is input string is not in correct format.
help me out in this regard.
here is my aspx code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NewCampaign.aspx.cs" Inherits="NoticeBoard.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">
<title></title> <style type="text/css">
.style1 { width: 160px; } .style2
{ width: 176px; } .style3 {
width: 160px; height: 23px; } .style4
{ width: 176px; height: 23px; }
.style5 { height: 23px; }
</style> </head>
<body style="height: 551px; width: 797px" bgcolor="White">
<form id="form1" runat="server">
<asp:GridView ID="noticeDetails" runat="server" EmptyDataText="Currently there are no notifications." BorderColor="White"
BorderWidth="1px" AutoGenerateColumns="false" PageSize="10" Width="100%" CellPadding="10">
<Columns>
<asp:BoundField DataField="CampaignIDRange" HeaderText="CampaignIDRange"
SortExpression="CampaignIDRange" InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="PromoStartDate" HeaderText="PromoStartDate"
SortExpression="PromoStartDate" />
<asp:BoundField DataField="PromoEndDate" HeaderText="PromoEndDate"
SortExpression="PromoEndDate" />
<asp:BoundField DataField="ExecutionDate" HeaderText="ExecutionDate"
SortExpression="ExecutionDate" />
<asp:BoundField DataField="ExpiryDate" HeaderText="ExpiryDate"
SortExpression="ExpiryDate" />
</Columns> </asp:GridView>
<table style="width:100%;"> <tr>
<td class="style1">
<asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack="true"
Text="Campaign ID Range" oncheckedchanged="RadioButton1_CheckedChanged" />
</td> <td class="style2">
<asp:TextBox ID="Txtadd5" runat="server"></asp:TextBox>
<asp:Label ID="Label5" runat="server" Text="to"></asp:Label>
</td>
<td>
<asp:TextBox ID="Txtadd6" runat="server"></asp:TextBox>
</td> </tr> <tr>
<td class="style1">
<asp:RadioButton ID="RadioButton2" runat="server" AutoPostBack="true" Text="Manual Entry"
oncheckedchanged="RadioButton2_CheckedChanged" />
</td>
<td class="style2">
<asp:TextBox ID="TextBox7" runat="server"></asp:TextBox>
</td> <td>
</td> </tr>
<tr> <td class="style1">
</td>
<td class="style2">
</td> <td>
</td> </tr>
<tr> <td class="style1">
<asp:Label ID="Label1" runat="server" Text="Promo Start Date"></asp:Label>
</td> <td class="style2">
<asp:TextBox ID="txtadd1" runat="server" ></asp:TextBox>
</td> <td>
</td> </tr>
<tr> <td class="style1">
<asp:Label ID="Label2" runat="server" Text="Promo End Date"></asp:Label>
</td> <td class="style2">
<asp:TextBox ID="txtadd2" runat="server"></asp:TextBox>
</td> <td>
</td> </tr>
<tr> <td class="style3">
<asp:Label ID="Label3" runat="server" Text="Execution Date"></asp:Label>
</td> <td class="style4">
<asp:TextBox ID="txtadd3" runat="server"></asp:TextBox>
</td> <td class="style5">
</td> </tr> <tr>
<td class="style1">
<asp:Label ID="Label4" runat="server" Text="Expiry Date"></asp:Label>
</td> <td class="style2">
<asp:TextBox ID="txtadd4" runat="server"></asp:TextBox>
</td> <td>
</td> </tr>
<tr> <td class="style1">
</td>
<td class="style2">
<asp:Button ID="Button1" runat="server" onclick="Button1_Click1"
Text="Submit" /> </td>
<td> </td>
</tr> </table> <p> </p>
</form> </body> </html>
here is my aspx.cs code
using System; using System.Configuration; using System.Collections.Generic;
using System.Linq; using System.Web; using System.Web.UI;
using System.Web.UI.WebControls; using System.Data.Odbc; using System.Data;
using System.Drawing; using System.Collections; using System.Web.Security;
using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls;
namespace NoticeBoard { public partial class WebForm1 : System.Web.UI.Page
{ DataTable dt;
protected void Page_Load(object sender, EventArgs e) {
dt = new DataTable("tblTest");
DataColumn dc1 = new DataColumn();
dc1.DataType = typeof(String);
dc1.ColumnName = "PromoStartDate";
DataColumn dc2 = new DataColumn();
dc2.DataType = typeof(String);
dc2.ColumnName = "PromoEndDate";
DataColumn dc3 = new DataColumn();
dc3.DataType = typeof(String);
dc3.ColumnName = "ExecutionDate";
DataColumn dc4 = new DataColumn();
dc4.DataType = typeof(String);
dc4.ColumnName = "ExpiryDate";
DataColumn dc5 = new DataColumn();
dc5.DataType = typeof(String);
dc5.ColumnName = "CampaignIDRange";
dt.Columns.Add(dc1); dt.Columns.Add(dc2);
dt.Columns.Add(dc3); dt.Columns.Add(dc4);
dt.Columns.Add(dc5); }
protected void TextBox3_TextChanged(object sender, EventArgs e)
{ }
protected void TextBox1_TextChanged(object sender, EventArgs e)
{ }
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{ if (RadioButton1.Checked == true) {
RadioButton2.Enabled = false; } else
{ RadioButton2.Enabled = true; }
}
protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
{ if (RadioButton2.Checked == true) {
RadioButton1.Enabled = false; } else
{ RadioButton1.Enabled = true; }
} protected void Button1_Click1(object sender, EventArgs e)
{ Session["PromoStartDate"] += txtadd1.Text + "|";
Session["PromoEndDate"] += txtadd2.Text + "|";
Session["ExecutionDate"] += txtadd3.Text + "|";
Session["ExpiryDate"] += txtadd4.Text + "|";
Session["CampaignIDRange"] += Txtadd5.Text + "|";
Session["CampaignIDRange2"] += Txtadd6.Text + "|";
CreateTable(); } public void CreateTable()
{
string[] sa = Session["PromoStartDate"].ToString().Split('|');
string[] sb = Session["PromoEndDate"].ToString().Split('|');
string[] sc = Session["ExecutionDate"].ToString().Split('|');
string[] sd = Session["ExpiryDate"].ToString().Split('|');
string[] se = Session["CampaignIDRange"].ToString().Split('|');
string[] sf = Session["CampaignIDRange2"].ToString().Split('|');
int recordnum = sa.Length;
for (int j = 0; j < recordnum - 1; j++) {
DataRow dr;
for (int k = Convert.ToInt32(se[j]); k <= Convert.ToInt32(sf[j]); k++)
{ dr = dt.NewRow();
dr["PromoStartDate"] = sa[j].ToString();
dr["PromoEndDate"] = sb[j].ToString();
dr["ExecutionDate"] = sc[j].ToString();
dr["ExpiryDate"] = sd[j].ToString();
dr["CampaignIDRange"] = k.ToString();
//dr["CampaignIDRange"] = sf[j].ToString();
dt.Rows.Add(dr); }
noticeDetails.DataSource = dt.DefaultView;
noticeDetails.DataBind(); } } }
}
help me in this regard!