the error is...........A potentially dangerous Request.Form value was detected from the client (dd3="<!--Select the item-...").
protected void Page_Load(object sender, EventArgs e)
{
con = new SqlConnection("server=SOFTWARE4;uid=sa;pwd=;database=Helpdesk1");
con.Open();
txt_date.Text = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt");
if (!Page.IsPostBack)
{
loaddata();
}
}
void loaddata()
{
string s = "select * from swift where swiftid='blk' and sid in(1,2,3,4,5)";
adp = new SqlDataAdapter(s, con);
ds = new DataSet();
adp.Fill(ds, "swift");
dd1.DataSource = ds.Tables["swift"].DefaultView;
dd1.DataTextField = "descriptions";
dd1.DataValueField = "sid";
dd1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
string a = "insert into swiftresult values(" + dd1.SelectedValue + "," + dd2.SelectedValue + "," + dd3.SelectedValue + ","+dd5.SelectedValue+",'" + dd4.SelectedValue + "','" + TextBox1.Text + "','"+txt_date.Text+"','n',null,null,null,null,null)";
SqlCommand cmd = new SqlCommand(a, con);
cmd.ExecuteNonQuery();
string b = "select callno from swiftresult where callno=(select max(callno) from swiftresult)";
SqlCommand cmd1 = new SqlCommand(b, con);
SqlDataReader dr = cmd1.ExecuteReader();
if (dr.Read())
{
Session["callno"] = dr["callno"];
}
dr.Close();
Response.Redirect("regist.aspx");
}
protected void dd1_SelectedIndexChanged(object sender, EventArgs e)
{
string a = "select distinct a.descriptions,a.sid from swift a,pc_link b where swiftid='loc'and a.sid=b.locationid and blockid="+dd1.SelectedValue;
adp = new SqlDataAdapter(a, con);
ds = new DataSet();
adp.Fill(ds, "swift");
dd2.DataSource = ds.Tables["swift"].DefaultView;
dd2.DataTextField = "descriptions";
dd2.DataValueField = "sid";
dd2.DataBind();
}
protected void dd2_SelectedIndexChanged(object sender, EventArgs e)
{
string b = "select distinct a.descriptions,b.depid from swift a,pc_link b where a.swiftid='dep' and b.blockid=" + dd1.SelectedValue + " and b.locationid=" + dd2.SelectedValue + " and a.sid=b.depid";
SqlDataAdapter adp1 = new SqlDataAdapter(b, con);
DataSet ds = new DataSet();
adp1.Fill(ds);
dd3.DataSource = ds;
dd3.DataTextField = "descriptions";
dd3.DataValueField ="depid";
dd3.DataBind();
}
protected void dd3_SelectedIndexChanged(object sender, EventArgs e)
{
string k = "select distinct a.descriptions,b.pcid from swift a,pc_link b where a.swiftid='pc' and b.blockid="+dd1.SelectedValue+" and b.locationid="+dd2.SelectedValue+"and a.sid=b.pcid and b.depid="+dd3.SelectedValue;
SqlDataAdapter adp3 = new SqlDataAdapter(k, con);
DataSet ds = new DataSet();
adp3.Fill(ds);
dd5.DataSource = ds;
dd5.DataTextField = "descriptions";
dd5.DataValueField = "pcid";
dd5.DataBind();
}
<body>
<form id="form1" runat="server">
<div>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:HelpdeskConnectionString %> "
SelectCommand="SELECT [blockid], [block] FROM [Helpdesk_block]"></asp:SqlDataSource>
<asp:TextBox ID="txt_date" runat="server" Visible="False"> </asp:TextBox>
<asp:Panel ID="Panel1" runat="server" BackColor="Teal" BorderColor="Teal" Height="7px"
Width="482px" Font-Bold="True" Font-Size="X-Large">
<asp:Panel ID="Panel2" runat="server" BackColor="White" Height="371px" Width="563px" BorderColor="Teal" BorderStyle="Solid">
<asp:Label ID="Label2" runat="server" Text="Block" Width="91px" Font-Bold="True" Font-Size="Medium"> </asp:Label>
<asp:DropDownList ID="dd1" runat="server" Width="130px" AutoPostBack="True" OnSelectedIndexChanged="dd1_SelectedIndexChanged" Font-Size="Small">
</asp:DropDownList>
<asp:Label ID="Label3" runat="server" Text="Location" Width="83px" Font-Bold="True" Font-Size="Medium"> </asp:Label>
<asp:DropDownList ID="dd2" runat="server" Width="130px" AutoPostBack="True" OnSelectedIndexChanged="dd2_SelectedIndexChanged" Font-Size="Small">
</asp:DropDownList> <br />
<asp:Label ID="Label4" runat="server" Text="Departments" Width="116px" Font-Bold="True" Font-Size="Medium"> </asp:Label>
<asp:DropDownList ID="dd3" runat="server" Width="130px" OnSelectedIndexChanged="dd3_SelectedIndexChanged" AutoPostBack="True" Font-Size="Small">
<asp:ListItem> <!--Select the item--></asp:ListItem>
</asp:DropDownList> <br />
<asp:Label ID="Label7" runat="server" Font-Size="Medium" Text="Pc-Name" Width="118px"> </asp:Label>
<asp:DropDownList ID="dd5" runat="server" AutoPostBack="True" Width="130px" Font-Size="Small">
</asp:DropDownList> <br />
<br />
<asp:Label ID="Label5" runat="server" Text="Problem Type" Width="115px" Font-Bold="True" Font-Size="Medium"> </asp:Label>
<asp:DropDownList ID="dd4" runat="server" AutoPostBack="True" Width="130px" OnSelectedIndexChanged="dd4_SelectedIndexChanged" Font-Size="Small">
<asp:ListItem> Software</asp:ListItem>
<asp:ListItem Selected="True"> Hardware</asp:ListItem>
<asp:ListItem> Others</asp:ListItem>
</asp:DropDownList> <br />
<asp:DropDownList ID="dd6" runat="server"
AutoPostBack="True" OnSelectedIndexChanged="dd6_SelectedIndexChanged" Width="130px" Visible="False" Font-Size="Small">
</asp:DropDownList> <br />
<br />
<div style="z-index: 102; left: 245px; width: 113px; position: absolute; top: 361px;
height: 35px">
<asp:Button ID="Button1" runat="server" Text="Save" Width="114px" OnClick="Button1_Click" /> </div>
<div style="z-index: 101; left: 116px; width: 179px; position: absolute; top: 283px;
height: 20px">
<asp:Label ID="Label6" runat="server" Text="Software Definitions" Width="104px" Font-Bold="True" Font-Size="Medium" Visible="False"> </asp:Label>
</div>
</asp:Panel>
</asp:Panel>
</div>
</div>
<div style="z-index: 102; left: 395px; width: 181px; position: absolute; top: 398px;
height: 47px">
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="Medium" Text="Hardware Definitions"
Width="109px" Visible="False"> </asp:Label> </div>
<div style="z-index: 103; left: 398px; width: 371px; position: absolute; top: 406px;
height: 49px">
<asp:Label ID="Label8" runat="server" Font-Size="Medium"
Text="Others Definitions" Visible="False" Font-Bold="True"> </asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Height="37px"
TextMode="MultiLine" Visible="False" Width="185px"> </asp:TextBox> </div>
</form>
</body>