Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Datagrid button

Reply
Thread Tools

Datagrid button

 
 
brock wade
Guest
Posts: n/a
 
      06-11-2008
I have a Datagrid that is working fine displying my records, but I'm
trying to program buttons
on each record line to launch another web page that shows all the
details for the product:

<asp:datagrid id="dgProducts" runat="server">
<asp:ButtonColumn Text="Details" CommandName="Details"
ButtonType="PushButton"></asp:ButtonColumn>
</asp:datagrid>


Should I go to my code-behind to do something like this?:


Sub detailsClicked(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
Response.Redirect("www.mysite.com\details.aspx")
End Sub


If so how can I pass the chosen record's key information into the new
page to pickup the details?
 
Reply With Quote
 
 
 
 
Munna
Guest
Posts: n/a
 
      06-12-2008
On Jun 12, 12:42 am, brock wade <(E-Mail Removed)> wrote:
> I have a Datagrid that is working fine displying my records, but I'm
> trying to program buttons
> on each record line to launch another web page that shows all the
> details for the product:
>
> <asp:datagrid id="dgProducts" runat="server">
> <asp:ButtonColumn Text="Details" CommandName="Details"
> ButtonType="PushButton"></asp:ButtonColumn>
> </asp:datagrid>
>
> Should I go to my code-behind to do something like this?:
>
> Sub detailsClicked(ByVal sender As Object, ByVal e As
> DataGridCommandEventArgs)
> Response.Redirect("www.mysite.com\details.aspx")
> End Sub
>
> If so how can I pass the chosen record's key information into the new
> page to pickup the details?


Hi

You are taking about master detail view of course.
check out this tutorial... i believe this is what you want...
http://www.asp.net/learn/data-access...ial-10-vb.aspx

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
 
Reply With Quote
 
 
 
 
brock wade
Guest
Posts: n/a
 
      06-12-2008
Thanks for the link. It looks good. Let me make sure I'm on the
correct path here. I have a DataGrid and the only change I've made so
far is adding "DataTextField="Key"

<asp:datagrid id="dgProducts" runat="server">
<asp:ButtonColumn Text="Details" CommandName="Details"
DataTextField="Key"
ButtonType="PushButton"></asp:ButtonColumn>
</asp:datagrid>

The reason I used "Key" is the way the code-behind ia setup (note the
dr.Key):

Private Sub SetListViewItem(ByVal dr As Employee, ByVal dt As
DataTable, ByVal count As Integer)
If count = 0 Then
dt.Columns.Add("Emp #")
dt.Columns.Add("Last Name")
dt.Columns.Add("First Name")
dt.Columns.Add("Title")
End If
Dim EmpPos As Action = (New
ActionBroker).GetActionCurrent(dr.Key, Today, Global.UserName,
Global.UserPassword, Global.appDataSource)
Dim employee As DataRow = dt.NewRow
employee("Emp #") = dr.Key
employee("Last Name") = dr.LastName
employee("First Name") = dr.FirstName
employee("Title") = EmpPos.WorkAgainstInfo.Title
dt.Rows.Add(employee)
End Sub 'SetListViewItem

When I run the page though it says that "A field or property with the
name 'Key' was not found on the selected datasource."

Any ideas?




On Jun 12, 4:23*am, Munna <(E-Mail Removed)> wrote:
> On Jun 12, 12:42 am, brock wade <(E-Mail Removed)> wrote:
>
>
>
>
>
> > I have a Datagrid that is working fine displying my records, but I'm
> > trying to program buttons
> > on each record line to launch another web page that shows all the
> > details for the product:

>
> > <asp:datagrid id="dgProducts" runat="server">
> > * * * * <asp:ButtonColumn Text="Details" CommandName="Details"
> > ButtonType="PushButton"></asp:ButtonColumn>
> > * * * * </asp:datagrid>

>
> > Should I go to my code-behind to do something like this?:

>
> > * * Sub detailsClicked(ByVal sender As Object, ByVal e As
> > DataGridCommandEventArgs)
> > * * * * Response.Redirect("www.mysite.com\details.aspx")
> > * * End Sub

>
> > If so how can I pass the chosen record's key information into the new
> > page to pickup the details?

>
> Hi
>
> You are taking about master detail view of course.
> check out this tutorial... i believe this is what you want...http://www.asp.net/learn/data-access...ial-10-vb.aspx
>
> Best of luck
>
> Munnawww.munna.shatkotha.comwww.munna.shatkotha.co m/blogwww.shatkotha.com- Hide quoted text -
>
> - Show quoted text -


 
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
image button click event fires before click event of button Purvi T ASP .Net 0 10-19-2004 06:19 AM
Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl. jorge ASP .Net 2 05-25-2004 11:45 PM
HTML Reset Button Doesn't work after postback with Submit button Chris Lane ASP .Net 4 11-17-2003 11:52 PM
To all Gurus: How can I edit/update a DataGrid in a DataGrid (nested DataGrid)? Possible? Andreas Klemt ASP .Net Datagrid Control 0 10-08-2003 01:19 AM
JavaScript Access to Button in form tags (webcontrol or html button) Wes Weems ASP .Net 1 07-20-2003 05:27 AM



Advertisments