Last post Apr 12, 2013 02:58 AM by Ajay2707
Apr 04, 2013 01:55 AM|its me89|LINK
I have one gridview, in that i have multiple Checkboxes.
My problem is that i want to display that records in Crystal Report which has been checked in checkbox.
If user selecte multiple Id and press button then all the checked value has been display in Crystal Report or regarding that Id, the value has been display.
For that I have Use Procedure, It will Work, But It display only One record at a time, When Select Multiple Id It will display blank report.
how can i do that?? I am Using VB 2008.
Plz help Me..
Apr 11, 2013 07:33 PM|thirumaran007|LINK
could you please share your SQL query ?
Apr 12, 2013 02:58 AM|Ajay2707|LINK
For your solution, you can set parameter as string with max width. Now while passing value of checkbox/s, sent value in a string with comma seperated value like '1,2,3,4...' .
In a sp , you can fetch data as value with comma separated value. Then you can modify your sp either 2 approach.
declare @str varchar(max), @par1 varchar(15)
set @par1 = '2,4,6,8,7,9,10'
select * from CustomerMaster where CustomerID in (2,4,6,8,7,9,10)
set @str = 'select * from CustomerMaster where CustomerID in ('+@par1+')';
exec sp_sqlexec @str
or 2 Change sp as below and make one function.
create Function SplitString (@List Varchar(Max), @Delimiter Char(1))
Returns @Items Table (Item Varchar(100))
Declare @Item Varchar(12), @Pos TinyInt While Len(@List) > 0
Begin Set @Pos = CharIndex(@Delimiter, @List)
If @Pos = 0 Set @Pos = Len(@List) + 1
Set @Item = Left(@List, @Pos - 1)
Set @List = SubString(@List, @Pos + Len(@Delimiter), Len(@List))
Declare @myTable Table(Id Int, Descs Varchar(max))
Insert Into @myTable
Select 1, '08190,737079,1004618,1075562,1272753,1390841,1544201,2591141'
Union All Select 2, '335395,359380,741049,1113212,2283999,2908851,2001205615'
Union All Select 3, '1212358,2451853,2795175,2001196872 'Select
tbl1.Id, tbl1.Descs, fn.Item
@myTable As tbl1
Cross Apply dbo.SplitString(tbl1.Descs, ',') As fn