Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Is it possible to acheive the following using a DataGrid in ASP.NE

Reply
Thread Tools

Is it possible to acheive the following using a DataGrid in ASP.NE

 
 
Ben (Melb, Vic, Aus)
Guest
Posts: n/a
 
      09-07-2005
I'm hoping that someone might be able to help me with the following challenge.

The problems lies in the ability to display rows and columns of data on a
datagrid conditionally.

I have a list of rows in a data grid with one of the columns being a date. I
have a hyperlink column for every row which allows me to remove a row from
the grid. I would like to disable the ability to remove a row if the date is
in the past, is this possible using a DataGrid?

Thanks in advance for your assistance.
Ben

 
Reply With Quote
 
 
 
 
Gerhard Pretorius
Guest
Posts: n/a
 
      09-07-2005
Yes, it is possible, but you must create a Template field with a Hyperlink control in it.
Then on the DataBid Event or (RowDataBound) of the grid, use this code.
In this code I check if a date exists and set the value of two different Hyperlinks...

The declaritive code looks like this (All ASP.NET 1.1) (In grid column)
<ItemTemplate>
<asp:HyperLink id="lnkEdit" runat="server" NavigateUrl="../Eval_EventEdit.aspx?Eval_EventGUID={0}">Edit Details
</ItemTemplate>
// get the datarow view of the item

DataRowView drv = (DataRowView)e.Item.DataItem;

if (drv == null) return;



// get the Answer Radio button that is being created

System.Web.UI.Control ctlEdit = e.Item.FindControl("lnkEdit");
if (ctlEdit != null)
{

HyperLink lnkEdit = (HyperLink)ctlEdit;

switch (drv["Eval_Date"].ToString().Length)

{

case 0:

// does an event exists

if (drv["Eval_EventGUID"].ToString().Length == 0)

{

// event does not exists

lnkEdit.Text = "Start First Evaluation";

lnkEdit.NavigateUrl = string.Format("../Eval_EventCreate.aspx?DealerID={0}", drv["DealerID"]);

}

else

{

lnkEdit.Text = "Complete results";

lnkEdit.NavigateUrl = string.Format(lnkEdit.NavigateUrl, drv["Eval_EventGUID"]);

}

break;

default:

lnkEdit.Text = "Edit/Print results/comments";

lnkEdit.NavigateUrl = string.Format(lnkEdit.NavigateUrl, drv["Eval_EventGUID"]);

break;

}

}

"Ben (Melb, Vic, Aus)" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> I'm hoping that someone might be able to help me with the following challenge.
>
> The problems lies in the ability to display rows and columns of data on a
> datagrid conditionally.
>
> I have a list of rows in a data grid with one of the columns being a date. I
> have a hyperlink column for every row which allows me to remove a row from
> the grid. I would like to disable the ability to remove a row if the date is
> in the past, is this possible using a DataGrid?
>
> Thanks in advance for your assistance.
> Ben
>

 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      09-07-2005
Thanks for Gerhard's informative suggestion.

Hi Ben,

As Gerhard has mentioned, we can use a template column instead of the
Buildin button column, and put a asp.net submit button in the template
column(set the proper commandName, such as "Edit", "Delete"...). Thus, we
can freely access the control in template column (through the DataGrid's
ItemDataBound" event) and modify the nested button's property according to
the binding data. Gerhard has provided some detailed code snippet, if you
still have any further question, please feel free to post here. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Gerhard Pretorius" <(E-Mail Removed)>
| References: <(E-Mail Removed)>
| Subject: Re: Is it possible to acheive the following using a DataGrid in
ASP.NE
| Date: Wed, 7 Sep 2005 09:11:53 +0200
| Lines: 222
| MIME-Version: 1.0
| Content-Type: multipart/alternative;
| boundary="----=_NextPart_000_0118_01C5B38C.305C35F0"
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| Message-ID: <(E-Mail Removed)>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| NNTP-Posting-Host: 196.15.187.131
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5477
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
|
| Yes, it is possible, but you must create a Template field with a
Hyperlink control in it.
| Then on the DataBid Event or (RowDataBound) of the grid, use this code.
| In this code I check if a date exists and set the value of two different
Hyperlinks...
| The declaritive code looks like this (All ASP.NET 1.1) (In grid column)
| <ItemTemplate>
| <asp:HyperLink id="lnkEdit" runat="server"
NavigateUrl="../Eval_EventEdit.aspx?Eval_EventGUID={0}">Edit Details
</ItemTemplate>
| // get the datarow view of the item
| DataRowView drv = (DataRowView)e.Item.DataItem;
| if (drv == null) return;
| // get the Answer Radio button that is being created
| System.Web.UI.Control ctlEdit = e.Item.FindControl("lnkEdit");
| if (ctlEdit != null)
| {
| HyperLink lnkEdit = (HyperLink)ctlEdit;
| switch (drv["Eval_Date"].ToString().Length)
| {
| case 0:
| // does an event exists
| if (drv["Eval_EventGUID"].ToString().Length == 0)
| {
| // event does not exists
| lnkEdit.Text = "Start First Evaluation";
| lnkEdit.NavigateUrl =
string.Format("../Eval_EventCreate.aspx?DealerID={0}", drv["DealerID"]);
| }
| else
| {
| lnkEdit.Text = "Complete results";
| lnkEdit.NavigateUrl = string.Format(lnkEdit.NavigateUrl,
drv["Eval_EventGUID"]);
| }
| break;
| default:
| lnkEdit.Text = "Edit/Print results/comments";
| lnkEdit.NavigateUrl = string.Format(lnkEdit.NavigateUrl,
drv["Eval_EventGUID"]);
| break;
| }
| }
| "Ben (Melb, Vic, Aus)" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
| > I'm hoping that someone might be able to help me with the following
challenge.
| >
| > The problems lies in the ability to display rows and columns of data on
a
| > datagrid conditionally.
| >
| > I have a list of rows in a data grid with one of the columns being a
date. I
| > have a hyperlink column for every row which allows me to remove a row
from
| > the grid. I would like to disable the ability to remove a row if the
date is
| > in the past, is this possible using a DataGrid?
| >
| > Thanks in advance for your assistance.
| > Ben
| >
|

 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      09-12-2005
Hi Ben,

Any progress on this issue? If there're any further question or anything
else we can help, please feel free to post here. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| X-Tomcat-ID: 205362784
| References: <(E-Mail Removed)>
<(E-Mail Removed)>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: http://www.velocityreviews.com/forums/(E-Mail Removed) (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Wed, 07 Sep 2005 08:51:16 GMT
| Subject: Re: Is it possible to acheive the following using a DataGrid in
ASP.NE
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| Message-ID: <(E-Mail Removed)>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| Lines: 98
| Path: TK2MSFTNGXA01.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5478
| NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
|
| Thanks for Gerhard's informative suggestion.
|
| Hi Ben,
|
| As Gerhard has mentioned, we can use a template column instead of the
| Buildin button column, and put a asp.net submit button in the template
| column(set the proper commandName, such as "Edit", "Delete"...). Thus, we
| can freely access the control in template column (through the DataGrid's
| ItemDataBound" event) and modify the nested button's property according
to
| the binding data. Gerhard has provided some detailed code snippet, if you
| still have any further question, please feel free to post here. Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure! www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
| --------------------
| | From: "Gerhard Pretorius" <(E-Mail Removed)>
| | References: <(E-Mail Removed)>
| | Subject: Re: Is it possible to acheive the following using a DataGrid
in
| ASP.NE
| | Date: Wed, 7 Sep 2005 09:11:53 +0200
| | Lines: 222
| | MIME-Version: 1.0
| | Content-Type: multipart/alternative;
| | boundary="----=_NextPart_000_0118_01C5B38C.305C35F0"
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| | Message-ID: <(E-Mail Removed)>
| | Newsgroups: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| | NNTP-Posting-Host: 196.15.187.131
| | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msft ngp13.phx.gbl
| | Xref: TK2MSFTNGXA01.phx.gbl
| microsoft.public.dotnet.framework.aspnet.datagridc ontrol:5477
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.datagridc ontrol
| |
| | Yes, it is possible, but you must create a Template field with a
| Hyperlink control in it.
| | Then on the DataBid Event or (RowDataBound) of the grid, use this code.
| | In this code I check if a date exists and set the value of two
different
| Hyperlinks...
| | The declaritive code looks like this (All ASP.NET 1.1) (In grid column)
| | <ItemTemplate>
| | <asp:HyperLink id="lnkEdit" runat="server"
| NavigateUrl="../Eval_EventEdit.aspx?Eval_EventGUID={0}">Edit Details
| </ItemTemplate>
| | // get the datarow view of the item
| | DataRowView drv = (DataRowView)e.Item.DataItem;
| | if (drv == null) return;
| | // get the Answer Radio button that is being created
| | System.Web.UI.Control ctlEdit = e.Item.FindControl("lnkEdit");
| | if (ctlEdit != null)
| | {
| | HyperLink lnkEdit = (HyperLink)ctlEdit;
| | switch (drv["Eval_Date"].ToString().Length)
| | {
| | case 0:
| | // does an event exists
| | if (drv["Eval_EventGUID"].ToString().Length == 0)
| | {
| | // event does not exists
| | lnkEdit.Text = "Start First Evaluation";
| | lnkEdit.NavigateUrl =
| string.Format("../Eval_EventCreate.aspx?DealerID={0}", drv["DealerID"]);
| | }
| | else
| | {
| | lnkEdit.Text = "Complete results";
| | lnkEdit.NavigateUrl = string.Format(lnkEdit.NavigateUrl,
| drv["Eval_EventGUID"]);
| | }
| | break;
| | default:
| | lnkEdit.Text = "Edit/Print results/comments";
| | lnkEdit.NavigateUrl = string.Format(lnkEdit.NavigateUrl,
| drv["Eval_EventGUID"]);
| | break;
| | }
| | }
| | "Ben (Melb, Vic, Aus)" <(E-Mail Removed)> wrote in message
| news:(E-Mail Removed)...
| | > I'm hoping that someone might be able to help me with the following
| challenge.
| | >
| | > The problems lies in the ability to display rows and columns of data
on
| a
| | > datagrid conditionally.
| | >
| | > I have a list of rows in a data grid with one of the columns being a
| date. I
| | > have a hyperlink column for every row which allows me to remove a row
| from
| | > the grid. I would like to disable the ability to remove a row if the
| date is
| | > in the past, is this possible using a DataGrid?
| | >
| | > Thanks in advance for your assistance.
| | > Ben
| | >
| |
|
|

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The Web server reported the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/822319ev1'. 'HTTP/1.1 500 Internal Server Error'. chanmm ASP .Net 2 09-07-2010 07:37 AM
How to acheive this .. sriram.nandakumar@gmail.com Javascript 5 05-05-2006 11:51 AM
the way to acheive ccna ? jh3ang Cisco 1 04-15-2006 09:21 PM
RE: The Web server reported the following error when attempting to create or open the Web project located at the following URL: <URL> =?Utf-8?B?VHJldm9yIEJlbmVkaWN0IFI=?= ASP .Net 0 06-07-2004 07:36 AM
How to acheive this effect? D.Yacovone Digital Photography 11 02-27-2004 07:59 AM



Advertisments