Problem in gridview using SP

Posted by Rickeybglr under ASP.NET on 8/29/2012 | Points: 10 | Views : 909 | Status : [Member] | Replies : 1
Hi All,

i am using sql datasource to display data in gridview and type as =Stored proc which has 5 parameters. the problem is that during configuration when i click on test query in data source it display the data. but fail to display in gridview. wats the problem???
datagrid is able to display data only in one condition when i pass all the parameters. if i pass any null value sql data source disply the data but grid view doesn't.
SP:
ALTER 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


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;




Responses

Posted by: Lalitha86 on: 8/30/2012 [Member] Starter | Points: 25

Up
0
Down

string sconn = ConfigurationManager.ConnectionStrings["ConIPOissues"].ToString();

SqlParameter[] param = new SqlParameter[1];

param[0] = new SqlParameter("@scrip_cd", SqlDbType.VarChar);



param[0].Value = 118;or param[0].Value = DBNull.Value;


ds = SqlHelper.ExecuteDataset(sconn, CommandType.StoredProcedure, "USP_DEBT_DMDSHD", param);
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
lbl_scriptname.Text = ds.Tables[0].Rows[1]["SCRIP_NAME"].ToString();
lblAson.Text = "As on " + (Convert.ToDateTime(ds.Tables[0].Rows[1]["maxdt"])).ToString("dd MMM yyyy | hh:mm tt");

grd_demand.DataSource = ds.Tables[0];
grd_demand.DataBind();

Rickeybglr, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response