Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Button Column Select.

Button Column Select.

Scheduled Pinned Locked Moved Web Development
htmldesignsecurityhelpquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nclauder
    wrote on last edited by
    #1

    Hi all, I have a datagrid with Button column select in form of hyperlink. On the same page, I have another datagrid that insert data and one column(Name) has Names of a user that is inserting data(using windows authentication). Now this is how it's supposed to work: When any user want to see data about a particular user it's a matter of selecting his name and the data Writen by the selected user should be the only ones to be shown. I got some examples on Google but they all seem not to be working. When a user is selected the page remains the same data is not selected. How would can I solve this problem? My code looks like this: HTML part: and code behind: private void dgoperation_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { SqlCommand myCommand=new SqlCommand(); myCommand.Connection=con; myCommand.CommandText="select * from dbo.DashBoard where Name = @Billing"; myCommand.Parameters.Add(new SqlParameter("@Billing",SqlDbType.VarChar,50)); myCommand.Parameters["@Billing"].Value= dgbilling; SqlDataAdapter myAdapter=new SqlDataAdapter(myCommand); DataSet ds = new DataSet(); myAdapter.Fill(ds); dgis.DataSource=ds; dgis.EditItemIndex = -1; dgis.DataBind(); } dgis: this is the datagrid that where user inserts data. dgbilling: this is the datagrid with the name list. Thanks.

    N 1 Reply Last reply
    0
    • N nclauder

      Hi all, I have a datagrid with Button column select in form of hyperlink. On the same page, I have another datagrid that insert data and one column(Name) has Names of a user that is inserting data(using windows authentication). Now this is how it's supposed to work: When any user want to see data about a particular user it's a matter of selecting his name and the data Writen by the selected user should be the only ones to be shown. I got some examples on Google but they all seem not to be working. When a user is selected the page remains the same data is not selected. How would can I solve this problem? My code looks like this: HTML part: and code behind: private void dgoperation_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { SqlCommand myCommand=new SqlCommand(); myCommand.Connection=con; myCommand.CommandText="select * from dbo.DashBoard where Name = @Billing"; myCommand.Parameters.Add(new SqlParameter("@Billing",SqlDbType.VarChar,50)); myCommand.Parameters["@Billing"].Value= dgbilling; SqlDataAdapter myAdapter=new SqlDataAdapter(myCommand); DataSet ds = new DataSet(); myAdapter.Fill(ds); dgis.DataSource=ds; dgis.EditItemIndex = -1; dgis.DataBind(); } dgis: this is the datagrid that where user inserts data. dgbilling: this is the datagrid with the name list. Thanks.

      N Offline
      N Offline
      nclauder
      wrote on last edited by
      #2

      I have corrected my statement and this time I'm getting this error: "Object reference not set to an instance of an object." And the error source: Line 219: myCommand.CommandText="select * from dbo.DashBoard where Name Like @Billing"; Line 220: myCommand.Parameters.Add(new SqlParameter("@Billing",SqlDbType.VarChar,50)); Line 221: myCommand.Parameters["@Billing"].Value= bc.Text; Line 222: SqlDataAdapter myAdapter=new SqlDataAdapter(myCommand); Line 223: DataSet ds = new DataSet(); This is my code: My code behind: private void dgoperation_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { System.Web.UI.WebControls.LinkButton bc=new System.Web.UI.WebControls.LinkButton(); bc=(System.Web.UI.WebControls.LinkButton)e.Item.Cells[0].FindControl("TeamBĀ­illing"); SqlCommand myCommand=new SqlCommand(); myCommand.Connection=con; myCommand.CommandText="select * from dbo.DashBoard where Name Like @Billing"; myCommand.Parameters.Add(new SqlParameter("@Billing",SqlDbType.VarChar, 50)); myCommand.Parameters["@Billing"].Value= bc.Text; SqlDataAdapter myAdapter=new SqlDataAdapter(myCommand); DataSet ds = new DataSet(); myAdapter.Fill(ds); dgis.DataSource=ds; dgis.EditItemIndex = -1; dgis.DataBind(); } How can I solve this? Thanks

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups