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

Thursday, March 29, 2012

Set Column Width in DataList

I have a datalist that displays data from an SQL Server 2000 DB. One of the
fields contains names in the format "LastName FI". When the data is
displayed for that field it seems to base the width of the column on the
longest value of LastName which means I often get the lastname on one line
and the first initial on a second line (I guess is breaks on the space?)

How can I circumvent that second line? I tried adding code to set the column
width but it is not having any effect?

WayneTry putting a <DIV> into the cell. Browsers tend to do whatever suits them
with tables.

"Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
news:e83PD54PEHA.1160@.TK2MSFTNGP09.phx.gbl...
> I have a datalist that displays data from an SQL Server 2000 DB. One of
the
> fields contains names in the format "LastName FI". When the data is
> displayed for that field it seems to base the width of the column on the
> longest value of LastName which means I often get the lastname on one line
> and the first initial on a second line (I guess is breaks on the space?)
> How can I circumvent that second line? I tried adding code to set the
column
> width but it is not having any effect?
> Wayne
Rick;

Sorry to be dense but I am not clear on how to use a <DIV> tag to prevent a
field from wrapping?

Wayne

"Rick Spiewak" <rickspiewak@.mindspring.com> wrote in message
news:uVKaH06PEHA.640@.TK2MSFTNGP09.phx.gbl...
> Try putting a <DIV> into the cell. Browsers tend to do whatever suits them
> with tables.
> "Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
> news:e83PD54PEHA.1160@.TK2MSFTNGP09.phx.gbl...
> > I have a datalist that displays data from an SQL Server 2000 DB. One of
> the
> > fields contains names in the format "LastName FI". When the data is
> > displayed for that field it seems to base the width of the column on the
> > longest value of LastName which means I often get the lastname on one
line
> > and the first initial on a second line (I guess is breaks on the space?)
> > How can I circumvent that second line? I tried adding code to set the
> column
> > width but it is not having any effect?
> > Wayne
Something like:
<DIV style="WIDTH: 100px"
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Set Column Width in DataList

I have a datalist that displays data from an SQL Server 2000 DB. One of the
fields contains names in the format "LastName FI". When the data is
displayed for that field it seems to base the width of the column on the
longest value of LastName which means I often get the lastname on one line
and the first initial on a second line (I guess is breaks on the space?)
How can I circumvent that second line? I tried adding code to set the column
width but it is not having any effect?
WayneTry putting a <DIV> into the cell. Browsers tend to do whatever suits them
with tables.
"Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
news:e83PD54PEHA.1160@.TK2MSFTNGP09.phx.gbl...
> I have a datalist that displays data from an SQL Server 2000 DB. One of
the
> fields contains names in the format "LastName FI". When the data is
> displayed for that field it seems to base the width of the column on the
> longest value of LastName which means I often get the lastname on one line
> and the first initial on a second line (I guess is breaks on the space?)
> How can I circumvent that second line? I tried adding code to set the
column
> width but it is not having any effect?
> Wayne
>
Rick;
Sorry to be dense but I am not clear on how to use a <DIV> tag to prevent a
field from wrapping?
Wayne
"Rick Spiewak" <rickspiewak@.mindspring.com> wrote in message
news:uVKaH06PEHA.640@.TK2MSFTNGP09.phx.gbl...
> Try putting a <DIV> into the cell. Browsers tend to do whatever suits them
> with tables.
> "Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
> news:e83PD54PEHA.1160@.TK2MSFTNGP09.phx.gbl...
> the
line
> column
>
Something like:
<DIV style="WIDTH: 100px">
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!

Set DataList SelectedIndex to data record

I want to set the SelectedIndex of a DataList control to equal a specific
record in the database. What is the easiest way to accomplish this??

Thanks,
David D. McCroryI know this is a simple request, but I could sure use some
help.....thanks...
"David D. McCrory" <dmccrory@.alltell.net> wrote in message
news:eylWxCV3DHA.1924@.TK2MSFTNGP10.phx.gbl...
> I want to set the SelectedIndex of a DataList control to equal a specific
> record in the database. What is the easiest way to accomplish this??
>
> Thanks,
> David D. McCrory
I'm not sure this is possible. What are you trying to accomplish? There
exists no dependency on a control and its durable datasource - at least not
yet. ASP 2.0 promises to change this.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"David D. McCrory" <dmccrory@.alltell.net> wrote in message
news:eylWxCV3DHA.1924@.TK2MSFTNGP10.phx.gbl...
> I want to set the SelectedIndex of a DataList control to equal a specific
> record in the database. What is the easiest way to accomplish this??
>
> Thanks,
> David D. McCrory

Set DataList SelectedIndex - 2nd Post

This is the second post for this question...please help!!

This is a fairly simple request...I am looking for some help...

I want to set the SelectedIndex of a DataList control to equal a specific
record in the database. What is the easiest way to accomplish this??

Thanks,
David D. McCroryDavid D. McCrory wrote:
> This is the second post for this question...please help!!
> This is a fairly simple request...I am looking for some help...
> I want to set the SelectedIndex of a DataList control to equal a specific
> record in the database. What is the easiest way to accomplish this??
>
> Thanks,
> David D. McCrory

I would add a handler for the ItemDataBound event of the DataList and
then the event args give you access to the current item and its data.

e.Item.DataItem gives the current item in the datasource; use this to
check for a certain value
e.Item.ItemIndex gives the current item's index

I believe you can set the selectedindex in this event; if not, set a
local/member var to the value and then after the DataBind, set it.

The other solution is to loop the items after the DataBind instead of
using the event, but doing the first way does one less loop.

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Thanks Craig...I will give it a try.....

"Craig Deelsnyder" <cdeelsny@.NO_SPAM_4_MEyahoo.com> wrote in message
news:OO0DxWv3DHA.2528@.tk2msftngp13.phx.gbl...
> David D. McCrory wrote:
> > This is the second post for this question...please help!!
> > This is a fairly simple request...I am looking for some help...
> > I want to set the SelectedIndex of a DataList control to equal a
specific
> > record in the database. What is the easiest way to accomplish this??
> > Thanks,
> > David D. McCrory
> I would add a handler for the ItemDataBound event of the DataList and
> then the event args give you access to the current item and its data.
> e.Item.DataItem gives the current item in the datasource; use this to
> check for a certain value
> e.Item.ItemIndex gives the current item's index
> I believe you can set the selectedindex in this event; if not, set a
> local/member var to the value and then after the DataBind, set it.
> The other solution is to loop the items after the DataBind instead of
> using the event, but doing the first way does one less loop.
> --
> Craig Deelsnyder
> Microsoft MVP - ASP/ASP.NET

Saturday, March 24, 2012

set focus to form after postback

Hi.

I have one datalist and i have done custom paging for it.

I have four link button "First","Previous","Next", "Last" for paging datalist

Now I want to do paging on key press like as Right arrow for Next,Left Arrow for Previous,..........

for that I am calling javascript on onkeypress event of form.

Now Its working fine but problem is that javascript is called only on form key press event.

so that I want to set out focus on form after every post back.

I am calling following line at last but not working.

this.form1.Focus();

plz any one can help me?

best regard

pathan

Try this Just a guess

<formdefaultfocus="form1"id="form1"runat="server">


not helpful

Thursday, March 22, 2012

Set length of container

Hi to anyone out there that is taking the time to read this. I'm new to
..net and any help given is appreciated.

I am displaying a datalist on a page and I want to limit the length of
the returned container.dataitem that is displayed to 39 characters. How
do i do this in asp.net? I can do this in classic asp by using the
len() function, but i'm a bit stuck on how to do it in asp.net.

Thanks for any help you can give, my code is below.

========================================
'code behind creating list

Dim SQLdata As String
Dim dDS As New DataSet()
SQLdata = "SELECT id, pagedata FROM tblContent WHERE level6 =
'" & sLev6 & "'"
sConn = "Provider=Microsoft.jet.OLEDB.4.0; Data Source=" &
dbPath & ";"

Dim myConnd As New OleDbConnection(sConn)
Dim myAdapterd As New OleDbDataAdapter(SQLdata, myConnd)
myConnd.Open()

Try
myAdapterd.Fill(dDS)
DLdata.DataSource = dDS.Tables(0).DefaultView
DLdata.DataBind()
Finally
myConnd.Close()
End Try

========================================
'code on aspx page displaying list

<asp:DataList ID="DLdata" runat="server" cssclass="DLdatagrid">
<ItemStyle CssClass="DLdata" />
<ItemTemplate>
<img src="http://pics.10026.com/?src=images/arrow.jpg" alt=""/> <a
href='pagedata.aspx?id=<%#DataBinder.Eval(Container.DataItem,
"id")%>'><%#DataBinder.Eval(Container.DataItem, "pagedata")%></a
</ItemTemplate>
</asp:DataListthe easiest way to do it is:

<%# left(DataBinder.Eval(Container.DataItem, "pagedata"), 39)%
Karl

--
http://www.openmymind.net/

<marcus.lecount@.googlemail.com> wrote in message
news:1138056537.361430.326800@.z14g2000cwz.googlegr oups.com...
> Hi to anyone out there that is taking the time to read this. I'm new to
> .net and any help given is appreciated.
> I am displaying a datalist on a page and I want to limit the length of
> the returned container.dataitem that is displayed to 39 characters. How
> do i do this in asp.net? I can do this in classic asp by using the
> len() function, but i'm a bit stuck on how to do it in asp.net.
> Thanks for any help you can give, my code is below.
> ========================================
> 'code behind creating list
> Dim SQLdata As String
> Dim dDS As New DataSet()
> SQLdata = "SELECT id, pagedata FROM tblContent WHERE level6 =
> '" & sLev6 & "'"
> sConn = "Provider=Microsoft.jet.OLEDB.4.0; Data Source=" &
> dbPath & ";"
> Dim myConnd As New OleDbConnection(sConn)
> Dim myAdapterd As New OleDbDataAdapter(SQLdata, myConnd)
> myConnd.Open()
> Try
> myAdapterd.Fill(dDS)
> DLdata.DataSource = dDS.Tables(0).DefaultView
> DLdata.DataBind()
> Finally
> myConnd.Close()
> End Try
> ========================================
> 'code on aspx page displaying list
> <asp:DataList ID="DLdata" runat="server" cssclass="DLdatagrid">
> <ItemStyle CssClass="DLdata" />
> <ItemTemplate>
> <img src="http://pics.10026.com/?src=images/arrow.jpg" alt=""/> <a
> href='pagedata.aspx?id=<%#DataBinder.Eval(Container.DataItem,
> "id")%>'><%#DataBinder.Eval(Container.DataItem, "pagedata")%></a>
> </ItemTemplate>
> </asp:DataList
Thanks Karl, I can't believe i missed that. Why do i always miss the
obvious?
Thanks for taking the time to answer, I appreciate your help.

Karl Seguin [MVP] wrote:
> the easiest way to do it is:
> <%# left(DataBinder.Eval(Container.DataItem, "pagedata"), 39)%>
> Karl
> --
> http://www.openmymind.net/
>
> <marcus.lecount@.googlemail.com> wrote in message
> news:1138056537.361430.326800@.z14g2000cwz.googlegr oups.com...
> > Hi to anyone out there that is taking the time to read this. I'm new to
> > .net and any help given is appreciated.
> > I am displaying a datalist on a page and I want to limit the length of
> > the returned container.dataitem that is displayed to 39 characters. How
> > do i do this in asp.net? I can do this in classic asp by using the
> > len() function, but i'm a bit stuck on how to do it in asp.net.
> > Thanks for any help you can give, my code is below.
> > ========================================
> > 'code behind creating list
> > Dim SQLdata As String
> > Dim dDS As New DataSet()
> > SQLdata = "SELECT id, pagedata FROM tblContent WHERE level6 =
> > '" & sLev6 & "'"
> > sConn = "Provider=Microsoft.jet.OLEDB.4.0; Data Source=" &
> > dbPath & ";"
> > Dim myConnd As New OleDbConnection(sConn)
> > Dim myAdapterd As New OleDbDataAdapter(SQLdata, myConnd)
> > myConnd.Open()
> > Try
> > myAdapterd.Fill(dDS)
> > DLdata.DataSource = dDS.Tables(0).DefaultView
> > DLdata.DataBind()
> > Finally
> > myConnd.Close()
> > End Try
> > ========================================
> > 'code on aspx page displaying list
> > <asp:DataList ID="DLdata" runat="server" cssclass="DLdatagrid">
> > <ItemStyle CssClass="DLdata" />
> > <ItemTemplate>
> > <img src="http://pics.10026.com/?src=images/arrow.jpg" alt=""/> <a
> > href='pagedata.aspx?id=<%#DataBinder.Eval(Container.DataItem,
> > "id")%>'><%#DataBinder.Eval(Container.DataItem, "pagedata")%></a>
> > </ItemTemplate>
> > </asp:DataList

Set length of container

Hi to anyone out there that is taking the time to read this. I'm new to
.net and any help given is appreciated.
I am displaying a datalist on a page and I want to limit the length of
the returned container.dataitem that is displayed to 39 characters. How
do i do this in asp.net? I can do this in classic asp by using the
len() function, but i'm a bit stuck on how to do it in asp.net.
Thanks for any help you can give, my code is below.
========================================
'code behind creating list
Dim SQLdata As String
Dim dDS As New DataSet()
SQLdata = "SELECT id, pagedata FROM tblContent WHERE level6 =
'" & sLev6 & "'"
sConn = "Provider=Microsoft.jet.OLEDB.4.0; Data Source=" &
dbPath & ";"
Dim myConnd As New OleDbConnection(sConn)
Dim myAdapterd As New OleDbDataAdapter(SQLdata, myConnd)
myConnd.Open()
Try
myAdapterd.Fill(dDS)
DLdata.DataSource = dDS.Tables(0).DefaultView
DLdata.DataBind()
Finally
myConnd.Close()
End Try
========================================
'code on aspx page displaying list
<asp:DataList ID="DLdata" runat="server" cssclass="DLdatagrid">
<ItemStyle CssClass="DLdata" />
<ItemTemplate>
<img src="http://pics.10026.com/?src=/library/images/arrow.jpg" alt=""/> <a
href='pagedata.aspx?id=<%#DataBinder.Eval(Container.DataItem,
"id")%>'><%#DataBinder.Eval(Container.DataItem, "pagedata")%></a>
</ItemTemplate>
</asp:DataList>the easiest way to do it is:
<%# left(DataBinder.Eval(Container.DataItem, "pagedata"), 39)%>
Karl
http://www.openmymind.net/
<marcus.lecount@.googlemail.com> wrote in message
news:1138056537.361430.326800@.z14g2000cwz.googlegroups.com...
> Hi to anyone out there that is taking the time to read this. I'm new to
> .net and any help given is appreciated.
> I am displaying a datalist on a page and I want to limit the length of
> the returned container.dataitem that is displayed to 39 characters. How
> do i do this in asp.net? I can do this in classic asp by using the
> len() function, but i'm a bit stuck on how to do it in asp.net.
> Thanks for any help you can give, my code is below.
> ========================================
> 'code behind creating list
> Dim SQLdata As String
> Dim dDS As New DataSet()
> SQLdata = "SELECT id, pagedata FROM tblContent WHERE level6 =
> '" & sLev6 & "'"
> sConn = "Provider=Microsoft.jet.OLEDB.4.0; Data Source=" &
> dbPath & ";"
> Dim myConnd As New OleDbConnection(sConn)
> Dim myAdapterd As New OleDbDataAdapter(SQLdata, myConnd)
> myConnd.Open()
> Try
> myAdapterd.Fill(dDS)
> DLdata.DataSource = dDS.Tables(0).DefaultView
> DLdata.DataBind()
> Finally
> myConnd.Close()
> End Try
> ========================================
> 'code on aspx page displaying list
> <asp:DataList ID="DLdata" runat="server" cssclass="DLdatagrid">
> <ItemStyle CssClass="DLdata" />
> <ItemTemplate>
> <img src="http://pics.10026.com/?src=/library/images/arrow.jpg" alt=""/> <a
> href='pagedata.aspx?id=<%#DataBinder.Eval(Container.DataItem,
> "id")%>'><%#DataBinder.Eval(Container.DataItem, "pagedata")%></a>
> </ItemTemplate>
> </asp:DataList>
>
Thanks Karl, I can't believe i missed that. Why do i always miss the
obvious?
Thanks for taking the time to answer, I appreciate your help.
Karl Seguin [MVP] wrote:
> the easiest way to do it is:
> <%# left(DataBinder.Eval(Container.DataItem, "pagedata"), 39)%>
> Karl
> --
> http://www.openmymind.net/
>
> <marcus.lecount@.googlemail.com> wrote in message
> news:1138056537.361430.326800@.z14g2000cwz.googlegroups.com...