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. dgresult.SelectedItem.Cells(1).Text

dgresult.SelectedItem.Cells(1).Text

Scheduled Pinned Locked Moved ASP.NET
questionhelp
4 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.
  • N Offline
    N Offline
    n_gchaitra
    wrote on last edited by
    #1

    Hi, can anyone say what is the error in the following code. the value present in the datagrid is not getting stored in the variable "assetcode". Protected Sub dgresult_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgresult.SelectedIndexChanged Dim assetcode As String assetcode = dgresult.SelectedItem.Cells(1).Text Response.Redirect("Edit_UPS.aspx?assetcode=" + assetcode + " ") End Sub

    R 1 Reply Last reply
    0
    • N n_gchaitra

      Hi, can anyone say what is the error in the following code. the value present in the datagrid is not getting stored in the variable "assetcode". Protected Sub dgresult_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgresult.SelectedIndexChanged Dim assetcode As String assetcode = dgresult.SelectedItem.Cells(1).Text Response.Redirect("Edit_UPS.aspx?assetcode=" + assetcode + " ") End Sub

      R Offline
      R Offline
      RepliCrux
      wrote on last edited by
      #2

      What is the error message you are getting?? There is no property of DataGrid called SelectedItem by the way !!

      N 1 Reply Last reply
      0
      • R RepliCrux

        What is the error message you are getting?? There is no property of DataGrid called SelectedItem by the way !!

        N Offline
        N Offline
        n_gchaitra
        wrote on last edited by
        #3

        It is not giving any error. But just not working. As I know this property is used to select the value in a particular column and in fact it is working for me in other pages. But I could not figure it out why it is not working here. Here is the complete code. Imports System.Web.Security Imports System.Data Imports System.Data.SqlClient Imports System.Web.Configuration Imports System.Collections Imports System.Data.SqlClient.SqlConnection Partial Class Searchups Inherits System.Web.UI.Page Dim sqlstr As String Dim vstr As String Dim flag As Boolean Dim constr As String = ConfigurationSettings.AppSettings("conn") Dim dbconn As New SqlConnection(constr) Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Txtasscd.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + Btnsearch.UniqueID + "').click();return false;}} else {return true}; ") Ddl.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + Btnsearch.UniqueID + "').click();return false;}} else {return true}; ") Ddmdl.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + Btnsearch.UniqueID + "').click();return false;}} else {return true}; ") tbreg.Visible = False tabdg.Visible = False Calendar1.Visible = False Calendar2.Visible = False If Page.IsPostBack = False Then bindmodel() bindlocation() bindoff() increment() bindmdl() vstr = ViewState("vstr") End If End Sub Sub bindmodel() Dim sqlstr As String sqlstr = "select model from a_upsmodel order by model" Dim comm As New SqlCommand(sqlstr, dbconn) Dim dr As SqlDataReader If dbconn.State <> ConnectionState.Open Then dbconn.Open() End If dr = comm.ExecuteReader While dr.Read Ddmdl.Items.Add(dr.Item(0).ToString) End While dr.Close() End Sub Sub bindresult(ByVal sqlstr As String) Dim ds As New DataSet() Dim comm As New SqlDataAdapter(sqlstr, dbconn) dgresult.DataSource = ds comm.Fill(ds) dgresult.DataBind() 'navi.Visible = True

        R 1 Reply Last reply
        0
        • N n_gchaitra

          It is not giving any error. But just not working. As I know this property is used to select the value in a particular column and in fact it is working for me in other pages. But I could not figure it out why it is not working here. Here is the complete code. Imports System.Web.Security Imports System.Data Imports System.Data.SqlClient Imports System.Web.Configuration Imports System.Collections Imports System.Data.SqlClient.SqlConnection Partial Class Searchups Inherits System.Web.UI.Page Dim sqlstr As String Dim vstr As String Dim flag As Boolean Dim constr As String = ConfigurationSettings.AppSettings("conn") Dim dbconn As New SqlConnection(constr) Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Txtasscd.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + Btnsearch.UniqueID + "').click();return false;}} else {return true}; ") Ddl.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + Btnsearch.UniqueID + "').click();return false;}} else {return true}; ") Ddmdl.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + Btnsearch.UniqueID + "').click();return false;}} else {return true}; ") tbreg.Visible = False tabdg.Visible = False Calendar1.Visible = False Calendar2.Visible = False If Page.IsPostBack = False Then bindmodel() bindlocation() bindoff() increment() bindmdl() vstr = ViewState("vstr") End If End Sub Sub bindmodel() Dim sqlstr As String sqlstr = "select model from a_upsmodel order by model" Dim comm As New SqlCommand(sqlstr, dbconn) Dim dr As SqlDataReader If dbconn.State <> ConnectionState.Open Then dbconn.Open() End If dr = comm.ExecuteReader While dr.Read Ddmdl.Items.Add(dr.Item(0).ToString) End While dr.Close() End Sub Sub bindresult(ByVal sqlstr As String) Dim ds As New DataSet() Dim comm As New SqlDataAdapter(sqlstr, dbconn) dgresult.DataSource = ds comm.Fill(ds) dgresult.DataBind() 'navi.Visible = True

          R Offline
          R Offline
          RepliCrux
          wrote on last edited by
          #4

          Sorry, my bad, I was thinking of Windows form, Whats the error Message by the way!!

          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