Getting data out of a datasource

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using a datalist control (dlist_myfavorites) and this control is bound
to a sqldatareader source. Datalist is basicly populated by the following sp.

CREATE PROCEDURE [select_favorites_bymguid]

(
@mguid as nvarchar(50) -- member guid id
)

AS

SELECT
cat.acname 'category',
adds.aid 'refno',
adds.miname 'image',
adds.teaseline1 'tl1',
adds.teaseline2 'tl2',
adds.teaseline3 'tl3',
adds.displayguid 'displayguid',
fav.entrydate 'entrydate',
adds.aguid 'aguid'


FROM tbl_adds_whole adds join tbl_member_favorites fav
ON(fav.aguid= adds.aguid) join tbl_add_categories cat
ON(adds.category=cat.acid)
WHERE fav.mguid = @mguid and cat.aclanguage =1


I have a hidden label inside the datalist that hold "aguid" data as below:
<asp:label id="aguid" visible=false runat=server><%#
databinder.eval(container.dataitem, "aguid") %></asp:label>

I am using a check box control with "delete" id in my datalist control, in
order to find out which items will be deleted. Once the user clicks on a
"btn_delete_selected" button process the following code:

Private Sub btn_delete_selected_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btn_delete_selected.Click

Dim isdeleted As Boolean

Dim anitem As DataListItem

Dim mguid As String = context.User.Identity.Name

Dim aguid As String

Dim mymf As memberfunctions = New memberfunctions

For Each anitem In dlist_myfavorites.Items

isdeleted = CType(anitem.FindControl("delete"), CheckBox).Checked

If isdeleted Then

aguid = CType(anitem.FindControl("aguid"), Label).Text

mymf.delete_tbl_member_favorites(aguid, mguid)

End If

Next

End Sub

The problem is aguid in the above sub always returns "" value eventhough I
have some rows selected on the page. On the other hand isdeleted variable
always returns right values either true or false. What am I doing wrong here?
Thank you in advance.
 
I believe the problem is that you cannot get the values after postback of a
hidden element.

Try making the checkbox visible and see if you still have the same
problem....if you don't, then you need to come up with a different way to
hold the variable.

Good luck.

KC
 
I did try to make the label that holds the aguid information visible and I
can see it on the page. However, it wont get it on the code when it is
processed. Any idea to get the value or another way to do it?

Kc said:
I believe the problem is that you cannot get the values after postback of a
hidden element.

Try making the checkbox visible and see if you still have the same
problem....if you don't, then you need to come up with a different way to
hold the variable.

Good luck.

KC

regaliel said:
I am using a datalist control (dlist_myfavorites) and this control is bound
to a sqldatareader source. Datalist is basicly populated by the following sp.

CREATE PROCEDURE [select_favorites_bymguid]

(
@mguid as nvarchar(50) -- member guid id
)

AS

SELECT
cat.acname 'category',
adds.aid 'refno',
adds.miname 'image',
adds.teaseline1 'tl1',
adds.teaseline2 'tl2',
adds.teaseline3 'tl3',
adds.displayguid 'displayguid',
fav.entrydate 'entrydate',
adds.aguid 'aguid'


FROM tbl_adds_whole adds join tbl_member_favorites fav
ON(fav.aguid= adds.aguid) join tbl_add_categories cat
ON(adds.category=cat.acid)
WHERE fav.mguid = @mguid and cat.aclanguage =1


I have a hidden label inside the datalist that hold "aguid" data as below:
<asp:label id="aguid" visible=false runat=server><%#
databinder.eval(container.dataitem, "aguid") %></asp:label>

I am using a check box control with "delete" id in my datalist control, in
order to find out which items will be deleted. Once the user clicks on a
"btn_delete_selected" button process the following code:

Private Sub btn_delete_selected_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btn_delete_selected.Click

Dim isdeleted As Boolean

Dim anitem As DataListItem

Dim mguid As String = context.User.Identity.Name

Dim aguid As String

Dim mymf As memberfunctions = New memberfunctions

For Each anitem In dlist_myfavorites.Items

isdeleted = CType(anitem.FindControl("delete"), CheckBox).Checked

If isdeleted Then

aguid = CType(anitem.FindControl("aguid"), Label).Text

mymf.delete_tbl_member_favorites(aguid, mguid)

End If

Next

End Sub

The problem is aguid in the above sub always returns "" value eventhough I
have some rows selected on the page. On the other hand isdeleted variable
always returns right values either true or false. What am I doing wrong here?
Thank you in advance.
 
Have you tried using the CommandArgument field? If you do this, then after
you do the CType and get the checkbox, you will then have your ID without
having to get an additional field.

If you need an example of this let me know.

KC


regaliel said:
I did try to make the label that holds the aguid information visible and I
can see it on the page. However, it wont get it on the code when it is
processed. Any idea to get the value or another way to do it?

Kc said:
I believe the problem is that you cannot get the values after postback of a
hidden element.

Try making the checkbox visible and see if you still have the same
problem....if you don't, then you need to come up with a different way to
hold the variable.

Good luck.

KC

regaliel said:
I am using a datalist control (dlist_myfavorites) and this control is bound
to a sqldatareader source. Datalist is basicly populated by the
following
sp.
CREATE PROCEDURE [select_favorites_bymguid]

(
@mguid as nvarchar(50) -- member guid id
)

AS

SELECT
cat.acname 'category',
adds.aid 'refno',
adds.miname 'image',
adds.teaseline1 'tl1',
adds.teaseline2 'tl2',
adds.teaseline3 'tl3',
adds.displayguid 'displayguid',
fav.entrydate 'entrydate',
adds.aguid 'aguid'


FROM tbl_adds_whole adds join tbl_member_favorites fav
ON(fav.aguid= adds.aguid) join tbl_add_categories cat
ON(adds.category=cat.acid)
WHERE fav.mguid = @mguid and cat.aclanguage =1


I have a hidden label inside the datalist that hold "aguid" data as below:
<asp:label id="aguid" visible=false runat=server><%#
databinder.eval(container.dataitem, "aguid") %></asp:label>

I am using a check box control with "delete" id in my datalist control, in
order to find out which items will be deleted. Once the user clicks on a
"btn_delete_selected" button process the following code:

Private Sub btn_delete_selected_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btn_delete_selected.Click

Dim isdeleted As Boolean

Dim anitem As DataListItem

Dim mguid As String = context.User.Identity.Name

Dim aguid As String

Dim mymf As memberfunctions = New memberfunctions

For Each anitem In dlist_myfavorites.Items

isdeleted = CType(anitem.FindControl("delete"), CheckBox).Checked

If isdeleted Then

aguid = CType(anitem.FindControl("aguid"), Label).Text

mymf.delete_tbl_member_favorites(aguid, mguid)

End If

Next

End Sub

The problem is aguid in the above sub always returns "" value eventhough I
have some rows selected on the page. On the other hand isdeleted variable
always returns right values either true or false. What am I doing
wrong
here?
Thank you in advance.
 
I have solved the problem by changing label control as follow:

<asp:label id="aguid" visible=false runat=server text="<%#
databinder.eval(container.dataitem, "aguid") %>"></asp:label>

Not its working properly. Thank you for your helps Kc.

Kc said:
Have you tried using the CommandArgument field? If you do this, then after
you do the CType and get the checkbox, you will then have your ID without
having to get an additional field.

If you need an example of this let me know.

KC


regaliel said:
I did try to make the label that holds the aguid information visible and I
can see it on the page. However, it wont get it on the code when it is
processed. Any idea to get the value or another way to do it?

Kc said:
I believe the problem is that you cannot get the values after postback of a
hidden element.

Try making the checkbox visible and see if you still have the same
problem....if you don't, then you need to come up with a different way to
hold the variable.

Good luck.

KC

I am using a datalist control (dlist_myfavorites) and this control is
bound
to a sqldatareader source. Datalist is basicly populated by the following
sp.

CREATE PROCEDURE [select_favorites_bymguid]

(
@mguid as nvarchar(50) -- member guid id
)

AS

SELECT
cat.acname 'category',
adds.aid 'refno',
adds.miname 'image',
adds.teaseline1 'tl1',
adds.teaseline2 'tl2',
adds.teaseline3 'tl3',
adds.displayguid 'displayguid',
fav.entrydate 'entrydate',
adds.aguid 'aguid'


FROM tbl_adds_whole adds join tbl_member_favorites fav
ON(fav.aguid= adds.aguid) join tbl_add_categories cat
ON(adds.category=cat.acid)
WHERE fav.mguid = @mguid and cat.aclanguage =1


I have a hidden label inside the datalist that hold "aguid" data as below:
<asp:label id="aguid" visible=false runat=server><%#
databinder.eval(container.dataitem, "aguid") %></asp:label>

I am using a check box control with "delete" id in my datalist control, in
order to find out which items will be deleted. Once the user clicks on a
"btn_delete_selected" button process the following code:

Private Sub btn_delete_selected_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btn_delete_selected.Click

Dim isdeleted As Boolean

Dim anitem As DataListItem

Dim mguid As String = context.User.Identity.Name

Dim aguid As String

Dim mymf As memberfunctions = New memberfunctions

For Each anitem In dlist_myfavorites.Items

isdeleted = CType(anitem.FindControl("delete"), CheckBox).Checked

If isdeleted Then

aguid = CType(anitem.FindControl("aguid"), Label).Text

mymf.delete_tbl_member_favorites(aguid, mguid)

End If

Next

End Sub

The problem is aguid in the above sub always returns "" value eventhough I
have some rows selected on the page. On the other hand isdeleted variable
always returns right values either true or false. What am I doing wrong
here?
Thank you in advance.
 
Back
Top