Showing posts with label datalist. Show all posts
Showing posts with label datalist. Show all posts

Tuesday, March 13, 2012

stuck on this one

I'm trying to find a label and the value within a datalist, i've done this i
n
the passed in the datalist_itemdatbound routine and worked likes a charm. No
w
I"m trying to do the samething in a seperate routine and I can't find the
value.
in the routine i'm getting the value of the checkbox, checked or not and
passing that correctly, I also want to the get a the value of the associated
label with the checkbox and i can't get that working.
I have this:
for I = o to datalist.items.count - 1
checked = datalist.items(I).findcontrol("checkbox")
text = datatlist.items(I).findcontrol("labelname")
value = value & checked.checked.tostring() & text.text.tostring()
next
i'm getting the checkbox value but not the text value.
any ideas why this is happening?I writing this in the C#. You will be able to convert it to the VB
CheckBox cb = (CheckBox)datalist.items[i].Controls.FindControl("checkbox");
bool cval = cb.Checked;
Label lbl = (Label)datalist.items[i].Controls.FindControl("label");
also you can use code like this:
CheckBox cb = (CheckBox)datalist.items[i].Controls[0];
bool cval = cb.Checked;
Label lbl = (Label)datalist.items[i].Controls[1];
in the C# the first control is 0 and in the VB the first control is 1
if your listItem has two controls you have to try to find control 1 and 2
bye
"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:F6EFC19C-B103-42DA-9B71-F09A8559C54A@.microsoft.com...
> I'm trying to find a label and the value within a datalist, i've done this
in
> the passed in the datalist_itemdatbound routine and worked likes a charm.
Now
> I"m trying to do the samething in a seperate routine and I can't find the
> value.
> in the routine i'm getting the value of the checkbox, checked or not and
> passing that correctly, I also want to the get a the value of the
associated
> label with the checkbox and i can't get that working.
> I have this:
> for I = o to datalist.items.count - 1
> checked = datalist.items(I).findcontrol("checkbox")
> text = datatlist.items(I).findcontrol("labelname")
> value = value & checked.checked.tostring() & text.text.tostring()
> next
> i'm getting the checkbox value but not the text value.
> any ideas why this is happening?
>
thats simialar to what i have and i can't get the label to be recognized:
For I = 0 To datalist.Items.Count - 1
checkbox= dlScores.Items(I).FindControl("chkStuff")
CarInformation= dlScores.Items(G).FindControl("CarStuff")
value = value & checkbox.Checked.ToString() & "|" &
CarInformation.text & "|"
Next I
"Michael Tkachev" wrote:

> I writing this in the C#. You will be able to convert it to the VB
> CheckBox cb = (CheckBox)datalist.items[i].Controls.FindControl("checkbox");
> bool cval = cb.Checked;
> Label lbl = (Label)datalist.items[i].Controls.FindControl("label");
> also you can use code like this:
> CheckBox cb = (CheckBox)datalist.items[i].Controls[0];
> bool cval = cb.Checked;
> Label lbl = (Label)datalist.items[i].Controls[1];
> in the C# the first control is 0 and in the VB the first control is 1
> if your listItem has two controls you have to try to find control 1 and 2
> bye
> "Mike" <Mike@.discussions.microsoft.com> wrote in message
> news:F6EFC19C-B103-42DA-9B71-F09A8559C54A@.microsoft.com...
> in
> Now
> associated
>
>

stuck on this one

I'm trying to find a label and the value within a datalist, i've done this in
the passed in the datalist_itemdatbound routine and worked likes a charm. Now
I"m trying to do the samething in a seperate routine and I can't find the
value.
in the routine i'm getting the value of the checkbox, checked or not and
passing that correctly, I also want to the get a the value of the associated
label with the checkbox and i can't get that working.

I have this:
for I = o to datalist.items.count - 1
checked = datalist.items(I).findcontrol("checkbox")
text = datatlist.items(I).findcontrol("labelname")
value = value & checked.checked.tostring() & text.text.tostring()
next

i'm getting the checkbox value but not the text value.

any ideas why this is happening?I writing this in the C#. You will be able to convert it to the VB

CheckBox cb = (CheckBox)datalist.items[i].Controls.FindControl("checkbox");
bool cval = cb.Checked;
Label lbl = (Label)datalist.items[i].Controls.FindControl("label");

also you can use code like this:

CheckBox cb = (CheckBox)datalist.items[i].Controls[0];
bool cval = cb.Checked;
Label lbl = (Label)datalist.items[i].Controls[1];

in the C# the first control is 0 and in the VB the first control is 1
if your listItem has two controls you have to try to find control 1 and 2

bye

"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:F6EFC19C-B103-42DA-9B71-F09A8559C54A@.microsoft.com...
> I'm trying to find a label and the value within a datalist, i've done this
in
> the passed in the datalist_itemdatbound routine and worked likes a charm.
Now
> I"m trying to do the samething in a seperate routine and I can't find the
> value.
> in the routine i'm getting the value of the checkbox, checked or not and
> passing that correctly, I also want to the get a the value of the
associated
> label with the checkbox and i can't get that working.
> I have this:
> for I = o to datalist.items.count - 1
> checked = datalist.items(I).findcontrol("checkbox")
> text = datatlist.items(I).findcontrol("labelname")
> value = value & checked.checked.tostring() & text.text.tostring()
> next
> i'm getting the checkbox value but not the text value.
> any ideas why this is happening?
thats simialar to what i have and i can't get the label to be recognized:

For I = 0 To datalist.Items.Count - 1
checkbox= dlScores.Items(I).FindControl("chkStuff")
CarInformation= dlScores.Items(G).FindControl("CarStuff")
value = value & checkbox.Checked.ToString() & "|" &
CarInformation.text & "|"
Next I

"Michael Tkachev" wrote:

> I writing this in the C#. You will be able to convert it to the VB
> CheckBox cb = (CheckBox)datalist.items[i].Controls.FindControl("checkbox");
> bool cval = cb.Checked;
> Label lbl = (Label)datalist.items[i].Controls.FindControl("label");
> also you can use code like this:
> CheckBox cb = (CheckBox)datalist.items[i].Controls[0];
> bool cval = cb.Checked;
> Label lbl = (Label)datalist.items[i].Controls[1];
> in the C# the first control is 0 and in the VB the first control is 1
> if your listItem has two controls you have to try to find control 1 and 2
> bye
> "Mike" <Mike@.discussions.microsoft.com> wrote in message
> news:F6EFC19C-B103-42DA-9B71-F09A8559C54A@.microsoft.com...
> > I'm trying to find a label and the value within a datalist, i've done this
> in
> > the passed in the datalist_itemdatbound routine and worked likes a charm.
> Now
> > I"m trying to do the samething in a seperate routine and I can't find the
> > value.
> > in the routine i'm getting the value of the checkbox, checked or not and
> > passing that correctly, I also want to the get a the value of the
> associated
> > label with the checkbox and i can't get that working.
> > I have this:
> > for I = o to datalist.items.count - 1
> > checked = datalist.items(I).findcontrol("checkbox")
> > text = datatlist.items(I).findcontrol("labelname")
> > value = value & checked.checked.tostring() & text.text.tostring()
> > next
> > i'm getting the checkbox value but not the text value.
> > any ideas why this is happening?
>

Stuck Passing a DataList to a User Component

Hello,

Stuck on this one: I have User Component that is the main content table on my web page. It simply serves as a table with decorative border and header. All content (mostly text) is placed inside this User Component on each of my web pages by accessing the UserControl's properties.

However, now I have a web page with a DataList control, and would love to place this control inside my UserControl, but am stuck.

In my previous pages, I access the UserControl's strContent property that sets the cell.text property to the text coming from my dbase, but once again, is it somehow possible to put my DataList inside this Cell or something similar.

Thanks again,
JohnHad the same problem, here's my solution:


<DefaultProperty("Title"), ParseChildrenAttribute(False), ToolboxData("<{0}:WindowPanel runat=server></{0}:WindowPanel>")> Public Class WindowPanel
Inherits System.Web.UI.WebControls.WebControl

Dim _title As String
Dim _cssclass As String
Dim _width As System.Web.UI.WebControls.Unit

<Bindable(True), Category("Appearance"), DefaultValue("")> Property [Title]() As String
Get
Return _title
End Get

Set(ByVal Value As String)
_title = Value
End Set
End Property

<Bindable(True), Category("Appearance"), DefaultValue("")> Overrides Property [CSSClass]() As String
Get
Return _cssclass
End Get

Set(ByVal Value As String)
_cssclass = Value
End Set
End Property
<Bindable(True), Category("Appearance"), DefaultValue("")> Overrides Property [Width]() As System.Web.UI.WebControls.Unit
Get
Return _width
End Get

Set(ByVal Value As System.Web.UI.WebControls.Unit)
_width = Value
End Set
End Property

Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
output.Write("<table border=""0"" cellspacing=""0"" cellpadding=""0"" style=""width:" & _width.ToString & ";border: 1px solid;border-collapse:collapse;"" class=""" & _cssclass & """>" & vbCrLf & _
" <tr>" & vbCrLf & _
" <td style=""padding: 3px; border: 1px solid;"" class=""" & _cssclass & """>" & _title & "</td>" & vbCrLf & _
" </tr>" & vbCrLf & _
" <tr>" & vbCrLf & _
" <td style=""padding: 3px;"">" & vbCrLf)
Me.RenderContents(output)
output.Write(" </td>" & vbCrLf & _
" </tr>" & vbCrLf & _
"</table>")
End Sub

End Class

The important thing to remember is the "ParseChildrenAttribute(False)" Statement to be able to include other controls within this custom control.