dgresult.SelectedItem.Cells(1).Text
-
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
-
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
-
What is the error message you are getting?? There is no property of DataGrid called SelectedItem by the way !!
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
-
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