Wrox Programmer Forums
|
BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2
This is the forum to discuss the Wrox book Professional ASP.NET 2.0 Server Control and Component Development by Dr. Shahram Khosravi; ISBN: 9780471793502
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 2.0 Server Control and Component Development ISBN: 978-0-471-79350-2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 6th, 2006, 04:00 AM
Authorized User
 
Join Date: Nov 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default Excuse me?

Partial Class TestMenu3
    Inherits System.Web.UI.Page

    Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim ds As SqlDataSource = CType(e.Row.FindControl("SqlDataSource2"), SqlDataSource)
            ds.SelectParameters("fkMenuItemID").DefaultValue = GridView1.DataKeys(e.Row.RowIndex).Value
        End If
    End Sub
End Class

I Think I need your help?
How can I write it by C#?
Thanks
 
Old November 6th, 2006, 04:04 AM
Authorized User
 
Join Date: Nov 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

public partial class _Menu4 : System.Web.UI.Page
{
    protected void GridView1_RowDataBound(object sender, EventArgs e)
    {

    }
}

???
???

 
Old November 6th, 2006, 03:39 PM
Wrox Author
 
Join Date: Aug 2006
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Kuuy,
Here is the C# version of your VB.NET code:

partial class TestMenu3 : System.Web.UI.Page
{
  protected void GridView1_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
  {
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
      SqlDataSource ds = (SqlDataSource)e.Row.FindControl("SqlDataSource2") ;
      ds.SelectParameters("fkMenuItemID").DefaultValue = GridView1.DataKeys(e.Row.RowIndex).Value;
    }
  }
}

By the way, this code snippet has some technical problems. For more information, please refer to the chapter of my book on data source controls and their interactions with data bound controls.

Cheers!
Shahram

-----------------------
Shahram Khosravi, Ph.D.
Author of Professional ASP.NET 2.0 Server Control and Component Development
 
Old November 7th, 2006, 10:42 PM
Authorized User
 
Join Date: Nov 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank your very much!


 
Old November 8th, 2006, 08:38 AM
Authorized User
 
Join Date: Nov 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

partial class Menu4 : System.Web.UI.Page
{
    protected void GridView1_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string mystring;
            SqlDataSource ds = (SqlDataSource)e.Row.FindControl("SqlDataSource2") ;
            ds.SelectParameters["fkMenuItemID"].DefaultValue = GridView1.DataKeys[e.Row.RowIndex].Value.ToString();
        }
    }
}

But It's not runs well.Beacouse of the System.ArgumentOutOfRangeException!
I'm so soory?I need your help again.
Thanks!

Ricky
Qu

 
Old November 8th, 2006, 12:34 PM
Authorized User
 
Join Date: Nov 2006
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yeah
I it's runs well
http://www.kuuy.com/Demo/20061102_Eb0001/testmenu4.aspx
Thanks!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Excuse me? kuuy BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 1 November 26th, 2006 11:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.