Showing posts with label datagrid. Show all posts
Showing posts with label datagrid. Show all posts

Wednesday, March 28, 2012

Subtracting Date in VB.Net

Need Help!

How do I write the following expression for my project limiting the number of entries on my datagrid by 30 days from Now():

<!--

SELECT * FROM tblGrid WHERE dateEntered between Now() - 30 and Now()

-->

note: dateEntered are the dates in my date field (mm-dd-yyyy)

Thanks a lot.

If you are using VB.NET, you can use DateTime.Add method. There's an exampe in the docs here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatetimeclassaddtopic.asp

Monday, March 26, 2012

Suggestion needed for huge DataGrid

Hi all:
Our web site uses 3-tier structure, the middle tier is a web service. We
also use Microsoft Data Access Application Block to access sql server.
Now I have to display a DataGrid with huge amount of data on web page,
of course the DataGrid has pager. But even though, the web service still
will return full DataSet to web server, and let web server to handle pages.
Since Microsoft Data Access Application Block does not support
SqlDataAdapter.Fill(DataSet, startReocrd, maxRecord, tableName) to reduce
the size of DataSet. Do you think there is a better way to improve
performace?
Yes, I can always extend Microsoft Data Access Application Block and
build my own pager.

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours HardyHi Hardy,

May I suggest two solutions:
-if the full set of lines is going to be requested sooner or later, fill the
DataSet and place it in the Cache for the first time, then read it from the
Cache.
-if you don't need the full set of lines, you may use the SqlDataReader
combined with a TOP N command in your SQL query.
--
To reply, remove a "l" before the @. sign.

Arnaud Weil - MCT, MCSD.Net, MCAD.Net

Saturday, March 24, 2012

Suggestions on how to Open a New Window from a data grid

I have a datagrid that holds a whole list of records about computers. I need
one column that is a hyperlink that when clicked will show the details of t
hat computer model. The hyper link needs to open in a new window and have an
address that is my page na
me (modelinfo.aspx). That part is easy, as this is built into the datagrid c
ontrol. But the last thing I need is a varible on it, so when the hyperlink
is clicked, a New page would open and have an address "modelinfo.aspx?Model=
" & what ever value is in t
he corresponding cell that was clicked. So if I clicked on Model "e20" the a
ddress bar would have to read "modelinfo.aspx?Model=e20" etc. Any suggesti
ons? Thanks
Billtry this in the datagrid..
<asp:HyperLink runat="server" Target=_blank Text='<%#
DataBinder.Eval(Container, "DataItem.Model") %>' NavigateUrl='<%#
DataBinder.Eval(Container, "DataItem.Model", "modelinfo.aspx?Model={0}"
)
%>'></asp:HyperLink>
Av.
"Bill" <anonymous@.discussions.microsoft.com> wrote in message
news:37BAE768-6513-47BE-AD69-4DC4903D4573@.microsoft.com...
>I have a datagrid that holds a whole list of records about computers. I
>need one column that is a hyperlink that when clicked will show the details
>of that computer model. The hyper link needs to open in a new window and
>have an address that is my page name (modelinfo.aspx). That part is easy,
>as this is built into the datagrid control. But the last thing I need is a
>varible on it, so when the hyperlink is clicked, a New page would open and
>have an address "modelinfo.aspx?Model=" & what ever value is in the
>corresponding cell that was clicked. So if I clicked on Model "e20" the
>address bar would have to read "modelinfo.aspx?Model=e20" etc. Any
>suggestions? Thanks
> Bill

Suggestions on how to Open a New Window from a data grid

I have a datagrid that holds a whole list of records about computers. I need one column that is a hyperlink that when clicked will show the details of that computer model. The hyper link needs to open in a new window and have an address that is my page name (modelinfo.aspx). That part is easy, as this is built into the datagrid control. But the last thing I need is a varible on it, so when the hyperlink is clicked, a New page would open and have an address "modelinfo.aspx?Model=" & what ever value is in the corresponding cell that was clicked. So if I clicked on Model "e20" the address bar would have to read "modelinfo.aspx?Model=e20" etc. Any suggestions? Thank

Billtry this in the datagrid..

<asp:HyperLink runat="server" Target=_blank Text='<%#
DataBinder.Eval(Container, "DataItem.Model") %>' NavigateUrl='<%#
DataBinder.Eval(Container, "DataItem.Model", "modelinfo.aspx?Model={0}")
%>'></asp:HyperLink
Av.

"Bill" <anonymous@.discussions.microsoft.com> wrote in message
news:37BAE768-6513-47BE-AD69-4DC4903D4573@.microsoft.com...
>I have a datagrid that holds a whole list of records about computers. I
>need one column that is a hyperlink that when clicked will show the details
>of that computer model. The hyper link needs to open in a new window and
>have an address that is my page name (modelinfo.aspx). That part is easy,
>as this is built into the datagrid control. But the last thing I need is a
>varible on it, so when the hyperlink is clicked, a New page would open and
>have an address "modelinfo.aspx?Model=" & what ever value is in the
>corresponding cell that was clicked. So if I clicked on Model "e20" the
>address bar would have to read "modelinfo.aspx?Model=e20" etc. Any
>suggestions? Thanks
> Bill

Sum a Datagrid row?

Hello all,

I have a datagrid that returns sales of items by month from an Oracle
table using a datareader like so:

Item |Jan |Feb | ... |Dec
itm1 |10 |5 | ... |6
itm2 |7 |2 | ... |8

I want to add a column to the end of the datagrid that would sum the
row:
Item |Jan |Feb | ... |Dec |Total
itm1 |10 |5 | ... |6 |21
itm2 |7 |2 | ... |8 |17

I would think that this would be easy to do, but I can only find
articles that explain how sum a column into a footer. Could someone
point me in the right direction? I've only been programming in
asp.net for about four months now, so the help is appreciated.Use the binding event of the Grid view (or DataGrid in .NET 1.1) and sum the
columsn there. Go ahead and explicitly add this column to the DataSet in the
designer (and the rest of the columns if you are wise). In the binding event
grab the current binding row and then access the columns in question.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside the box!
*************************************************
"ClevelandSteve" <syahnert@.hotmail.comwrote in message
news:1155759519.915735.90550@.i42g2000cwa.googlegro ups.com...

Quote:

Originally Posted by

Hello all,
>
I have a datagrid that returns sales of items by month from an Oracle
table using a datareader like so:
>
Item |Jan |Feb | ... |Dec
itm1 |10 |5 | ... |6
itm2 |7 |2 | ... |8
>
I want to add a column to the end of the datagrid that would sum the
row:
Item |Jan |Feb | ... |Dec |Total
itm1 |10 |5 | ... |6 |21
itm2 |7 |2 | ... |8 |17
>
I would think that this would be easy to do, but I can only find
articles that explain how sum a column into a footer. Could someone
point me in the right direction? I've only been programming in
asp.net for about four months now, so the help is appreciated.
>


I got it working now. Thank you for the tip.

Sum on datagrid

How can I get the sum of an itemcolumn in a datagrid? I know I can use a seperate query to get it, but I would like to know how I can get the product listing and Sum using the same query

ThanksHi there,

Try this linkDisplaying Sum Total in a DataGrid

Hope this helps

Thursday, March 22, 2012

suppressing Submit command with a Delete button

I have a Delete button in my datagrid. I'm attempting to add some code
confirming whether the user wishes to really delete the item or not.

The confirm pops up, but I cannot suppress the submission when selecting
Cancel.

Heres what I have so far:

' adding the javascript call to the button:
Private Sub dgItem_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgItem.ItemCreated

If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
ListItemType.AlternatingItem Then

Dim objDeleteButton As Button = CType(e.Item.Cells(1).Controls(0), Button)

objDeleteButton.CssClass = "inputbutton"

objDeleteButton.Attributes.Add("onClick", "confirmDeleteItem();")

End If

End Sub

' client side code in javascript

function confirmDeleteItem()

{

if (confirm("Are you sure you wish to delete this item?"))

{

return true;

}

else

{

return false;

}

}

any help is appreciated. thank you.Sounds like you have validation controls on there, which causes the runtime
to emit yet another onClick handler which submits the form. Try using an
<input type="button"> instead of an <asp:button> control, and if you need
validation just script in the validation call (and, as always, make sure you
explicitly validate on the server, as client side validation is easy to
foil).

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Elliot M. Rodriguez" <elliotmrodriguezatnospamhotmail.com> wrote in message
news:%23xSgcJ$wDHA.2092@.TK2MSFTNGP09.phx.gbl...
> I have a Delete button in my datagrid. I'm attempting to add some code
> confirming whether the user wishes to really delete the item or not.
> The confirm pops up, but I cannot suppress the submission when selecting
> Cancel.
> Heres what I have so far:
> ' adding the javascript call to the button:
> Private Sub dgItem_ItemCreated(ByVal sender As Object, ByVal e As
> System.Web.UI.WebControls.DataGridItemEventArgs) Handles
dgItem.ItemCreated
> If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
> ListItemType.AlternatingItem Then
> Dim objDeleteButton As Button = CType(e.Item.Cells(1).Controls(0), Button)
> objDeleteButton.CssClass = "inputbutton"
> objDeleteButton.Attributes.Add("onClick", "confirmDeleteItem();")
> End If
> End Sub
>
> ' client side code in javascript
> function confirmDeleteItem()
> {
> if (confirm("Are you sure you wish to delete this item?"))
> {
> return true;
> }
> else
> {
> return false;
> }
> }
> any help is appreciated. thank you.
Chris:

Thanks for the reply. I am struggling with this.

If I take your approach it seems I dont have the ability to wire it to the
DeleteCommand event. This means I have to access the DataKey for the row
through the client, which I dont want to do. I could be wrong on this
though.

All I really want to do is have a DeleteCommand button that performs a
delete with a confirmation prior to deletion. My code does not have any
other validators on the page. There is another button on the page, but
performs a completely unrelated task.

"Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
news:uV5h$Y$wDHA.3220@.tk2msftngp13.phx.gbl...
> Sounds like you have validation controls on there, which causes the
runtime
> to emit yet another onClick handler which submits the form. Try using an
> <input type="button"> instead of an <asp:button> control, and if you need
> validation just script in the validation call (and, as always, make sure
you
> explicitly validate on the server, as client side validation is easy to
> foil).
> --
> Chris Jackson
> Software Engineer
> Microsoft MVP - Windows Client
> Windows XP Associate Expert
> --
> More people read the newsgroups than read my email.
> Reply to the newsgroup for a faster response.
> (Control-G using Outlook Express)
> --
> "Elliot M. Rodriguez" <elliotmrodriguezatnospamhotmail.com> wrote in
message
> news:%23xSgcJ$wDHA.2092@.TK2MSFTNGP09.phx.gbl...
> > I have a Delete button in my datagrid. I'm attempting to add some code
> > confirming whether the user wishes to really delete the item or not.
> > The confirm pops up, but I cannot suppress the submission when selecting
> > Cancel.
> > Heres what I have so far:
> > ' adding the javascript call to the button:
> > Private Sub dgItem_ItemCreated(ByVal sender As Object, ByVal e As
> > System.Web.UI.WebControls.DataGridItemEventArgs) Handles
> dgItem.ItemCreated
> > If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
> > ListItemType.AlternatingItem Then
> > Dim objDeleteButton As Button = CType(e.Item.Cells(1).Controls(0),
Button)
> > objDeleteButton.CssClass = "inputbutton"
> > objDeleteButton.Attributes.Add("onClick", "confirmDeleteItem();")
> > End If
> > End Sub
> > ' client side code in javascript
> > function confirmDeleteItem()
> > {
> > if (confirm("Are you sure you wish to delete this item?"))
> > {
> > return true;
> > }
> > else
> > {
> > return false;
> > }
> > }
> > any help is appreciated. thank you.
Aha - that's a special case I hadn't considered.

Try this article:

http://authors.aspalliance.com/aldo...xamples/cd.aspx

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Elliot M. Rodriguez" <someemail> wrote in message
news:ucDxzLAxDHA.2460@.TK2MSFTNGP10.phx.gbl...
> Chris:
> Thanks for the reply. I am struggling with this.
> If I take your approach it seems I dont have the ability to wire it to the
> DeleteCommand event. This means I have to access the DataKey for the row
> through the client, which I dont want to do. I could be wrong on this
> though.
> All I really want to do is have a DeleteCommand button that performs a
> delete with a confirmation prior to deletion. My code does not have any
> other validators on the page. There is another button on the page, but
> performs a completely unrelated task.
>
> "Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
> news:uV5h$Y$wDHA.3220@.tk2msftngp13.phx.gbl...
> > Sounds like you have validation controls on there, which causes the
> runtime
> > to emit yet another onClick handler which submits the form. Try using an
> > <input type="button"> instead of an <asp:button> control, and if you
need
> > validation just script in the validation call (and, as always, make sure
> you
> > explicitly validate on the server, as client side validation is easy to
> > foil).
> > --
> > Chris Jackson
> > Software Engineer
> > Microsoft MVP - Windows Client
> > Windows XP Associate Expert
> > --
> > More people read the newsgroups than read my email.
> > Reply to the newsgroup for a faster response.
> > (Control-G using Outlook Express)
> > --
> > "Elliot M. Rodriguez" <elliotmrodriguezatnospamhotmail.com> wrote in
> message
> > news:%23xSgcJ$wDHA.2092@.TK2MSFTNGP09.phx.gbl...
> > > I have a Delete button in my datagrid. I'm attempting to add some code
> > > confirming whether the user wishes to really delete the item or not.
> > > > The confirm pops up, but I cannot suppress the submission when
selecting
> > > Cancel.
> > > > Heres what I have so far:
> > > > ' adding the javascript call to the button:
> > > Private Sub dgItem_ItemCreated(ByVal sender As Object, ByVal e As
> > > System.Web.UI.WebControls.DataGridItemEventArgs) Handles
> > dgItem.ItemCreated
> > > > If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
> > > ListItemType.AlternatingItem Then
> > > > Dim objDeleteButton As Button = CType(e.Item.Cells(1).Controls(0),
> Button)
> > > > objDeleteButton.CssClass = "inputbutton"
> > > > objDeleteButton.Attributes.Add("onClick", "confirmDeleteItem();")
> > > > End If
> > > > End Sub
> > > > > > ' client side code in javascript
> > > > function confirmDeleteItem()
> > > > {
> > > > if (confirm("Are you sure you wish to delete this item?"))
> > > > {
> > > > return true;
> > > > }
> > > > else
> > > > {
> > > > return false;
> > > > }
> > > > }
> > > > any help is appreciated. thank you.
> >
Chris:

I realized I forgot the lousy "return" keyword in Attributes.Add lol...
Thanks for the article and the help.

"Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
news:OwfPeBBxDHA.1196@.TK2MSFTNGP12.phx.gbl...
> Aha - that's a special case I hadn't considered.
> Try this article:
> http://authors.aspalliance.com/aldo...xamples/cd.aspx
>
> --
> Chris Jackson
> Software Engineer
> Microsoft MVP - Windows Client
> Windows XP Associate Expert
> --
> More people read the newsgroups than read my email.
> Reply to the newsgroup for a faster response.
> (Control-G using Outlook Express)
> --
> "Elliot M. Rodriguez" <someemail> wrote in message
> news:ucDxzLAxDHA.2460@.TK2MSFTNGP10.phx.gbl...
> > Chris:
> > Thanks for the reply. I am struggling with this.
> > If I take your approach it seems I dont have the ability to wire it to
the
> > DeleteCommand event. This means I have to access the DataKey for the row
> > through the client, which I dont want to do. I could be wrong on this
> > though.
> > All I really want to do is have a DeleteCommand button that performs a
> > delete with a confirmation prior to deletion. My code does not have any
> > other validators on the page. There is another button on the page, but
> > performs a completely unrelated task.
> > "Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
> > news:uV5h$Y$wDHA.3220@.tk2msftngp13.phx.gbl...
> > > Sounds like you have validation controls on there, which causes the
> > runtime
> > > to emit yet another onClick handler which submits the form. Try using
an
> > > <input type="button"> instead of an <asp:button> control, and if you
> need
> > > validation just script in the validation call (and, as always, make
sure
> > you
> > > explicitly validate on the server, as client side validation is easy
to
> > > foil).
> > > > --
> > > Chris Jackson
> > > Software Engineer
> > > Microsoft MVP - Windows Client
> > > Windows XP Associate Expert
> > > --
> > > More people read the newsgroups than read my email.
> > > Reply to the newsgroup for a faster response.
> > > (Control-G using Outlook Express)
> > > --
> > > > "Elliot M. Rodriguez" <elliotmrodriguezatnospamhotmail.com> wrote in
> > message
> > > news:%23xSgcJ$wDHA.2092@.TK2MSFTNGP09.phx.gbl...
> > > > I have a Delete button in my datagrid. I'm attempting to add some
code
> > > > confirming whether the user wishes to really delete the item or not.
> > > > > > The confirm pops up, but I cannot suppress the submission when
> selecting
> > > > Cancel.
> > > > > > Heres what I have so far:
> > > > > > ' adding the javascript call to the button:
> > > > Private Sub dgItem_ItemCreated(ByVal sender As Object, ByVal e As
> > > > System.Web.UI.WebControls.DataGridItemEventArgs) Handles
> > > dgItem.ItemCreated
> > > > > > If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
> > > > ListItemType.AlternatingItem Then
> > > > > > Dim objDeleteButton As Button = CType(e.Item.Cells(1).Controls(0),
> > Button)
> > > > > > objDeleteButton.CssClass = "inputbutton"
> > > > > > objDeleteButton.Attributes.Add("onClick", "confirmDeleteItem();")
> > > > > > End If
> > > > > > End Sub
> > > > > > > > > > ' client side code in javascript
> > > > > > function confirmDeleteItem()
> > > > > > {
> > > > > > if (confirm("Are you sure you wish to delete this item?"))
> > > > > > {
> > > > > > return true;
> > > > > > }
> > > > > > else
> > > > > > {
> > > > > > return false;
> > > > > > }
> > > > > > }
> > > > > > any help is appreciated. thank you.
> > > > > >

Tuesday, March 13, 2012

svg graphic in datagrid

Hi,

How can I place a svg graphic in a datagrid ??Use a template column has one of you're datagrid columns. You can have any html you want in a template column including image tags.
yeah I know about the template column. I just wanted to know that if the image tags can support svg files. I will try it. thanks,

Switch between TextBox and Label inside DataGrid

I have DataGrid with Label in one of its columns. Label should change into
TextBox, when user do some specific action. How can I acomplish this??

P.S. Sorry for multiple posts in the same newsgroup, but I had to do that,
because my OE news reader doesn't show all my posts.I'm trying this:

<asp:TemplateColumn HeaderText="Sum">
<ItemTemplate>
<asp:Label id="lblSum" runat="server" Text='<%#
Container.DataItem("Sum") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtSum" runat="server" Text='<%#
Container.DataItem("Sum") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn
but when I do this:

DataGrid1.EditItemIndex = index

all DataGrid fields in selected row becomes editable and I wan't only one
specific field to be editable (TextBox). What should I do? :(
You need to make an ItemTemplate including both the label and the textbox
and control their visibility depending
on user actions. For an experienced javascript programmer I would recommend
doing it on client side. Otherwise you can do it on server side, possibly
with AJAX or other similar technologies.

Eliyahu

"John Smith" <john.smith@.microsoft.com> wrote in message
news:gcchg.3497$oj5.1152372@.news.siol.net...
> I have DataGrid with Label in one of its columns. Label should change into
> TextBox, when user do some specific action. How can I acomplish this??
>
> P.S. Sorry for multiple posts in the same newsgroup, but I had to do that,
> because my OE news reader doesn't show all my posts.
Hi,

I think you want to edit values by switching between label and textbox. The
following link would be very helpful.

http://www.syncfusion.com/FAQ/aspnet/WEB_c4c.aspx#q391q

Thanks
Sharmila

"John Smith" <john.smith@.microsoft.com> wrote in message
news:gcchg.3497$oj5.1152372@.news.siol.net...
> I have DataGrid with Label in one of its columns. Label should change into
> TextBox, when user do some specific action. How can I acomplish this??
>
> P.S. Sorry for multiple posts in the same newsgroup, but I had to do that,
> because my OE news reader doesn't show all my posts.
Thanks.

Switch between TextBox and Label inside DataGrid

I have DataGrid with Label in one of its columns. Label should change into
TextBox, when user do some specific action. How can I acomplish this'
P.S. Sorry for multiple posts in the same newsgroup, but I had to do that,
because my OE news reader doesn't show all my posts.I'm trying this:
<asp:TemplateColumn HeaderText="Sum">
<ItemTemplate>
<asp:Label id="lblSum" runat="server" Text='<%#
Container.DataItem("Sum") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtSum" runat="server" Text='<%#
Container.DataItem("Sum") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
but when I do this:
DataGrid1.EditItemIndex = index
all DataGrid fields in selected row becomes editable and I wan't only one
specific field to be editable (TextBox). What should I do? :(
You need to make an ItemTemplate including both the label and the textbox
and control their visibility depending
on user actions. For an experienced javascript programmer I would recommend
doing it on client side. Otherwise you can do it on server side, possibly
with AJAX or other similar technologies.
Eliyahu
"John Smith" <john.smith@.microsoft.com> wrote in message
news:gcchg.3497$oj5.1152372@.news.siol.net...
> I have DataGrid with Label in one of its columns. Label should change into
> TextBox, when user do some specific action. How can I acomplish this'
>
> P.S. Sorry for multiple posts in the same newsgroup, but I had to do that,
> because my OE news reader doesn't show all my posts.
>
Hi,
I think you want to edit values by switching between label and textbox. The
following link would be very helpful.
http://www.syncfusion.com/FAQ/aspnet/WEB_c4c.aspx#q391q
Thanks
Sharmila
"John Smith" <john.smith@.microsoft.com> wrote in message
news:gcchg.3497$oj5.1152372@.news.siol.net...
> I have DataGrid with Label in one of its columns. Label should change into
> TextBox, when user do some specific action. How can I acomplish this'
>
> P.S. Sorry for multiple posts in the same newsgroup, but I had to do that,
> because my OE news reader doesn't show all my posts.
>
Thanks.