K ) Grid Image FileUploader , ass (resume insert and DownLoad HyperLink)
* Grid Image *
* Imagefield is used in gridview
Properties Of ImageField :- 1)Dataimageurl :- column name 2) Dataimageformatstring :- ~/foldername/{0}
* Step :- create page (gridimg) -- gridview --
select grid -- [>] -- edit column --- bound field(id,name) -- Imagefield(pic) --
add image field properties 1)Dataimageurlfield :-column name (pic)--2)Dataimageurlformatsting
:- ~/foldername/{0}
Q ) How to set Gridview Imgaefield height and Width
Add tag And Attribute in source Under ImageField Tag :- <ControlStyle BorderColor="ActiveBorder" Height="100px" Width="100px" />
* Assigment :- Student resume insert and Download *
1st page :- insert data img with checkbox condition i true then submit data and show next page
2nd page :- show data in gridview and download img
Design Code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Lass_GridIMG_(P1mgHyperlikCheck).aspx.cs" Inherits="Lass_GridIMG_imgHyperlikCheck" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
<strong>Assigment no : 8 GridIMG,HYPErlink(download),CHeckbox </strong><br />
<br />
</div>
<div>
srno
<asp:TextBox ID="txtsrno" runat="server" ReadOnly="True"></asp:TextBox>
<br />
<br />
name
<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
<br />
<br />
email
<asp:TextBox ID="txtemail" runat="server"></asp:TextBox>
<br />
<br />
mobile
<asp:TextBox ID="txtmobile" runat="server"></asp:TextBox>
<br />
<br />
state
<asp:TextBox ID="txtstate" runat="server"></asp:TextBox>
<br />
<br />
city
<asp:TextBox ID="txtcity" runat="server"></asp:TextBox>
<br />
<br />
qualification
<asp:TextBox ID="txtqulifi" runat="server"></asp:TextBox>
<br />
<br />
collage
<asp:TextBox ID="txtclg" runat="server"></asp:TextBox>
<br />
<br />
semester
<asp:TextBox ID="txtsem" runat="server"></asp:TextBox>
<br />
<br />
file upload
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<br />
<asp:Image ID="Image1" runat="server" Height="111px" Width="189px" />
<br />
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="upload"
Height="45px" Width="109px" />
<br />
<br />
<asp:CheckBox ID="CheckBox1" runat="server" />
i agree terms and condition<br />
<br />
<asp:Button ID="Button2" runat="server" Text="submit" onclick="Button2_Click"
Height="40px" Width="106px" />
<br />
<br />
</div>
</form>
<p>
Fileupload krne ke bad display pe show krne ke liye IMAGE controle lagaya jata
hai ,,LABEL img name show ke liye hai</p>
</body>
</html>
Page Code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
public partial class Lass_GridIMG_imgHyperlikCheck : System.Web.UI.Page
{
SqlConnection cn;
SqlCommand cm;
SqlDataReader dr;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
protected void Button1_Click(object sender, EventArgs e)
{
FileUpload1.SaveAs(Server.MapPath("~") + "/pic/" + FileUpload1.FileName);
Image1.ImageUrl = "~/pic/" + FileUpload1.FileName;
Label1.Text = FileUpload1.FileName;
}
protected void Button2_Click(object sender, EventArgs e)
{
string path = @"Data Source=.\SQLEXPRESS;Initial Catalog=vnit;Integrated Security=True";
cn = new SqlConnection(path);
cn.Open();
string k1 = "select count(srno)+1 from rsupload1"; // auto genarate srno
cm = new SqlCommand(k1, cn);
txtsrno.Text = cm.ExecuteScalar().ToString();
if (CheckBox1.Checked == true)
{
string k = "insert into rsupload1(srno,name,email,mobile,state,city,qualification,college,semester,fileupload)values(@srno1,@name1,@email1,@mobile1,@state1,@city1,@qualification1,@college1,@semester1,@fileupload1)";
cm = new SqlCommand(k, cn);
cm.Parameters.AddWithValue("srno1", txtsrno.Text);
cm.Parameters.AddWithValue("name1", txtname.Text);
cm.Parameters.AddWithValue("email1", txtemail.Text);
cm.Parameters.AddWithValue("mobile1", txtmobile.Text);
cm.Parameters.AddWithValue("state1", txtstate.Text);
cm.Parameters.AddWithValue("city1", txtcity.Text);
cm.Parameters.AddWithValue("qualification1", txtqulifi.Text);
cm.Parameters.AddWithValue("college1", txtclg.Text);
cm.Parameters.AddWithValue("semester1", txtsem.Text);
cm.Parameters.AddWithValue("fileupload1", Label1.Text);
cm.ExecuteNonQuery();
Response.Write("data submited succesfully");
Response.Redirect("Lass_GridIMG_(P2mgHyperlikCheck).aspx");
}
else
{
Response.Write(" agree terms and condition");
}
}
}
Comments
Post a Comment