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. ASP.NET
  4. Two Part GridView Question

Two Part GridView Question

Scheduled Pinned Locked Moved ASP.NET
questionhelp
2 Posts 2 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.
  • E Offline
    E Offline
    E L Golpe
    wrote on last edited by
    #1

    ONE I have a ButtonField column in a GridView like so:

    asp:ButtonField DataTextField="Day" HeaderText="Date" CommandName="Detail"

    It lists the dates.. like 2,3,4,5,6 and so on in each GridRow. I want to fetch the date as an integer. I tried:

    int nDay = Convert.ToInt32(gvStats.SelectedRow.Cells[0].Text);

    but the SelectedRow is null. How do I go about it? ie:What object holds the correct value? TWO In my former DataGrid I have:

    if (dgClicks.DataKeys[dgItem.DataSetIndex] != System.DBNull.Value)

    can this be written as

    if (gvClick.DataKeys[gvRow.DataSetIndex].Value != System.DBNull.Value)

    Will it work correctly? Is this a valid conditional? ANY help on either would be GREATLY appreciated. Thanks Practice sesquipedalianism! ;)

    M 1 Reply Last reply
    0
    • E E L Golpe

      ONE I have a ButtonField column in a GridView like so:

      asp:ButtonField DataTextField="Day" HeaderText="Date" CommandName="Detail"

      It lists the dates.. like 2,3,4,5,6 and so on in each GridRow. I want to fetch the date as an integer. I tried:

      int nDay = Convert.ToInt32(gvStats.SelectedRow.Cells[0].Text);

      but the SelectedRow is null. How do I go about it? ie:What object holds the correct value? TWO In my former DataGrid I have:

      if (dgClicks.DataKeys[dgItem.DataSetIndex] != System.DBNull.Value)

      can this be written as

      if (gvClick.DataKeys[gvRow.DataSetIndex].Value != System.DBNull.Value)

      Will it work correctly? Is this a valid conditional? ANY help on either would be GREATLY appreciated. Thanks Practice sesquipedalianism! ;)

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Question 1: The SelectedRow property of the GridView control is null until you make a Select command, so you may replace the command name "Detail" with the "Select". If you want to use "Detail" as the command name, you can simply convert the ButtonField into a TemplateField with a Button so that you can pass the Day value in the CommandArgument property. You may also keep using the ButtonField with the Day value passed along with the CommandName. Question 2: The GridViewRow class does not have the DataSetIndex property, but it has a similar one named DataItemIndex, so it can rewritten like this:

      if (gvClick.DataKeys[gvRow.DataItemIndex].Value != System.DBNull.Value)

      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