Hi All,
i have a store procedure with some parameters. but i dnt want to display all the columns in a grid view, so have to hide some columns. the othr thing is one column contain imagepath. so need to bind this with imageField of datagrid view. how can i do ths. i dnt wanna use sqlDataSource wizard;
here is my code:
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);
conn.Open();
SqlCommand cmd = new SqlCommand("USP_ExtendedSearch", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@searchUsers", txtContactsSearch.Text.Trim());
cmd.Parameters.AddWithValue("@Name", txtSearchNames.Text.Trim());
cmd.Parameters.AddWithValue("@City", txtSearchCities.Text.Trim());
cmd.Parameters.AddWithValue("@email", txtEmail.Text.Trim());
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
da.SelectCommand = cmd;
SqlDataReader reader = cmd.ExecuteReader();
gv.DataSource = reader;
gv.DataBind();
conn.Close();
store proc:
LTER PROCEDURE [dbo].[USP_ExtendedSearch]
(
--@userName NVARCHAR(30),
@searchUsers NVARCHAR(30),
@Name NVARCHAR(30),
@City NVARCHAR(30),
@email NVARCHAR(30)
)
AS
BEGIN
SELECT a.userID,a.username AS UName,
a.firstname+' '+a.lastname AS Name,
a.useremail AS EmailID,
a.city AS City,
b.imagePath as ImagePath
FROM userRegistrationTB a
JOIN imageTB b
ON
a.userID=b.UserID
WHERE
--a.username!=@userName
--AND
a.username LIKE '%'+ISNULL(@searchUsers,'')+'%'
AND a.firstname LIKE '%'+ISNULL(@Name,'')+'%'
AND a.city LIKE '%'+ISNULL(@City,'')+'%'
AND a.useremail LIKE '%'+ISNULL(@email,'')+'%'
SET NOCOUNT ON;
END