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. Datagrid Problem

Datagrid Problem

Scheduled Pinned Locked Moved ASP.NET
databasehelp
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.
  • D Offline
    D Offline
    Devkranth Kishore Vanja
    wrote on last edited by
    #1

    hi all i have a problem please suggest me the solution i have a datagrid which consists of bounded columns i need to get the column number or column index datagrid sample is like this where heading channel and corporate are link buttons dynamically displayed slno | region Name |channel | corporate| 1 | abc |ruleset | forapproval 2 | a23 |ruleset | forapproval 3 | 2asdas |ruleset | forapproval 4 | adas |ruleset | forapproval so when i click on channel->ruleset i need to get the column no as 2.. based updon the column number i need to display the details if 2 then channel details else corporate details please .. its very urgent

    H 1 Reply Last reply
    0
    • D Devkranth Kishore Vanja

      hi all i have a problem please suggest me the solution i have a datagrid which consists of bounded columns i need to get the column number or column index datagrid sample is like this where heading channel and corporate are link buttons dynamically displayed slno | region Name |channel | corporate| 1 | abc |ruleset | forapproval 2 | a23 |ruleset | forapproval 3 | 2asdas |ruleset | forapproval 4 | adas |ruleset | forapproval so when i click on channel->ruleset i need to get the column no as 2.. based updon the column number i need to display the details if 2 then channel details else corporate details please .. its very urgent

      H Offline
      H Offline
      Herman T Instance
      wrote on last edited by
      #2

      Hi, I would make the column ruleset a LinkButton. In your aspx you create a TemplateField that has a LinkButton like:

      <asp:LinkButton runat="server" ID="lbRuleSet" CommandName="EditGrid" OnCommand="Grid_OnCommand" />
      

      In the codebehind you create a Method like:

       protected void Grid_OnCommand(Object sender, CommandEventArgs e)
              {
                  LinkButton btn = (LinkButton)sender;
                  GridViewRow row = (GridViewRow)btn.NamingContainer;
                  if (e.CommandName.Equals("EditGrid"))
                  {
                      MyGridView.SelectedIndex = row.RowIndex;
                      // now you have MyGridView.SelectedValue available and you can 
                      // display your details, as I believe you want to now the row the
                      // user selected in stead of the clumnnumber it clicked
                      MyGridView.SelectedIndex = -1; //to have no selectedrow again
                  }
      
              }
      
      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