.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan
Santhakumar Munuswamy
Fauzul Azmi
Asad Ali
Post New Web Links

Grid view update problem in asp.net c#

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :ASP.Net
 

Here is my complete code.....please tel where is the problem as i want to update the row in gridview.....and my textbox txtBox1,txtBox2,txtBox3 are having null .........and i'm getting error on the line SqlCommand cmd = new SqlCommand("update product set prodname = '" + txtBox2.Text + "' , proddesc = '" + txtBox3.Text + "' where prodid = " + txtBox1.Text + "", conn); saying that 

 

Object reference not set to an instance of an object.



public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnadd_Click(object sender, EventArgs e)
    {
        
        string pname=txtprodname.Text;
        string pdesc=txtdesc.Text;
        SqlConnection conn = new SqlConnection("Data Source=ABC-59236A7CB6F;Initial Catalog=practical2;Integrated Security=True");
        conn.Open();
         SqlCo


View Complete Post


More Related Resource Links

ASP.NET Grid View Paging and GridDataRowBound Problem -

  

Hi,

I have a problem displaying data in a Grid View control when I set a row to visible = false when a certain condition is true.

For example, if a DataRowData value has a condition set to true (custom in table) I set the visible property to false, so the data row will not be visible at run time.

The problem is that I'm using paging (10 rows per page) and if 8 of those rows fall into the true condition that won't show the row, that grid view page will only show two rows of data in page 1. The worst scenario is that if I go to page 2 of the grid view and all the rows (10) fall into the true condition, that grid view page will not show any data at all.

How can I show 10 rows of data at all times in a gridview? In other words, I would like to just show the visible rows at all times.

Any help will be greatly appreciated.

Eduardo.


grid view image delete problem

  
i have a grid in which i am showing a record with image, when user delete the record the image also deleted and when it again enter the record it upload the new image but display the deleted image from the cache example: name.jpeg upload, then deleted, a different file with the name.jpeg upload, it showing the deleted one. 

Grid view update error

  
Server Error in '/WebSite6' Application. Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:1. Add a "Debug=true" directive at the top of the file that generated the error. Example:   <%@ Page Language="C#" Debug="true" %>or:2) Add the following section to the configuration file of your application:<configuration>    <system.web>        <compilation debug="true"/>    </system.web></configuration> Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.Important: Running applicatio

Grid view delete problem

  
i hav a problem with delete in gridview.my backend is oracle 10g.it throws a ORA-01036 exception when i press delete button.here's my link to code. using System; using System.Collections; using System.Configuration; using System.Data; using System.Data.Odbc; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.OracleClient; public partial class Default2 : System.Web.UI.Page { OracleConnection con = new OracleConnection("Data Source=XE;User ID=SYSTEM;Password=****;Unicode=True"); OracleCommand cmd; DataSet ds = new DataSet(); OracleDataAdapter oda; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { getdata(); } } protected void Button1_Click(object sender, EventArgs e) { cmd = new OracleCommand("insert into petitioner values("+ TextBox6.Text +",'"+ TextBox1.Text +"',"+ TextBox2.Text +","+ TextBox3.Text +","+ TextBox4.Text +","+ TextBox5.Text +")", con); cmd.Connection.Open(); cmd.ExecuteNonQuery(); cmd.Connection.Close(); getdata();

Grid view control problem

  
HiI am using the grid view control where i am using <asp:CommandField for editing & deleting i want to visible false of this coloumn with edit & delete button..how do this.Thanks<asp:GridView DataKeyNames="StaffCalendarId"  PagerSettings-Mode="NumericFirstLast"                                                        PagerStyle-HorizontalAlign="Center" ShowHeader="true" AllowPaging="true" AutoGenerateColumns="False"                                                        Width="100%" ID="gvEventInfo" runat="server" CellPadding="4" ForeColor="#333333"                            &nbs

problem showing limited characters in grid view

  
Hi,Is it possible to show only few characters in gridview column. Lets say there are 5 columns in the gridview and one of the field is the description field. assume description field is too long. So What i want is to show that description field value to 50 character limit.my code is like this: <asp:BoundField DataField="ProposalDescription" HeaderStyle-CssClass="endTime" HeaderText="Proposal Description" ItemStyle-CssClass="endTime"> <HeaderStyle CssClass="endTime" /> <ItemStyle CssClass="endTime" /> </asp:BoundField> Now here i want to insert character limit for this datafield. Is it possible ?

Problem of data grid view of xml file

  
Dear Friends I have a problem with XML View Data Grid. Earlier I create .xml file, then type first set of data tags then Right Click on it and select View Data Grid and Visual Studio 2005 gives me nice data grid view where I can able to enter data. But in Visual Studio 2008 I am not able to find that option. So friends kindly tell me how to enter data with data grid in xml file? I am using ASP.net with  C#, Visual Studio 2008, XML file for createing data source. Thank you.

how to update a Grid view using Ajex

  

how to update a Grid view using Ajex



my query is select * From erp where emp>10;


then update the grdi view using ajex if any button Click


unable to update data to databse from grid view

  

I have two tables in my database

using "innerconnect" i have show table content in grid view as      INV_NO            INV_DT        DN_NO       DN_DT   LR_NO        LR_DT .

where LR_NO is null .

I want to update it from grid view plz help




TABLES









here  DN_NO  and INV_NO are primary keys

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace amar
{
    public partial class Form2 : Form
    {
        SqlConnection con;
        SqlDataAdapter da1,da2;
        SqlCommandBuilder cb;
    &nb

Grid view event problem

  

i call a sql

  SELECT (a.LASTMSG-a.MODIFIED) as mydate FROM DOC a

if


mydate <30   grid 1 color is red

mydate <45  grid 1 color is blue

mydate <450   grid 1 color is blue

it is apply on grid coloum how do it


problem in selecting deslecting multiple records in grid view by clicking control key.plz help

  

i want to select/deselect multiple records inside grid view by clicking control key.I can do the selection but the deselection is not working properly..there is some thing wrong in the  logic.plz help me to solve the problem.

my java script function is like..

<script language="javascript" type="text/javascript">

    function FillColor(cellid, id, evt) {
    
        var isSelected = document.getElementById('<%=hidSelectedRow.ClientID%>');
        alert(cellid);
        if (!evt) var evt = window.event;
        ctrlPressed = evt.ctrlKey;
        if (!ctrlPressed) {
            //alert(ctrlPressed);
            var clearCellColor = document.getElementById('hidCellId').value.split(',');
            for (i = 0; i < clearCellColor.length; i++) {
                document.getElementById(clearCellColor[i]).bgCol

problem in selecting deslecting multiple records in grid view by clicking control key through java

  

i want to select/deselect multiple records inside grid view by clicking control key.I can do the selection but the deselection is not working properly..there is some thing wrong in the  logic.plz help me to solve the problem.

my java script function is like..

<script language="javascript" type="text/javascript">

    function FillColor(cellid, id, evt) {
    
        var isSelected = document.getElementById('<%=hidSelectedRow.ClientID%>');
        alert(cellid);
        if (!evt) var evt = window.event;
        ctrlPressed = evt.ctrlKey;
        if (!ctrlPressed) {
            //alert(ctrlPressed);
            var clearCellColor = document.getElementById('hidCellId').value.split(',');
            for (i = 0; i < clearCellColor.length; i++) {
                document.getElementById(clearCellColor[i]).bgC

Grid view width problem

  

how to fix grid view width using jqery


update two tables from single grid view using stored procedure PLZ help

  

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace INV_DN
{
    public partial class Form1 : Form
    {
        SqlConnection con;
        SqlDataAdapter da1;
        SqlCommand cmd;
        //  SqlCommandBuilder cb;
        DataSet ds;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            con = new SqlConnection("User Id=sa;Password=123;database=amar");
            cmd = new SqlCommand("getdata", con);

Grid view Problem

  

i am create a user control for grid view i pass sqL string to main (aspx page) and that show the grid view sql in ascx page how to do it


how to asp.net update panel use in Tree view and grid view

  

how to asp.net update panel use in Tree view and grid view


Problem in Nested grid view edit.

  


Hi All ,

I have Parent grid view (gvServiceDetail)  and child grid view (Gridview2) in Parent grid view. Child grid view has 3 bound column. In Parent grid view I am binding Partnername,Area,Mobile and in child grid I am binding services against partnerid.

Now I want to edit service details row in child grid view.

<asp:GridView ID="gvServiceDetail" runat="server" AutoGenerateColumns="False" Width="90%"
                                        DataKeyNames="Partner_code">
                                        <Columns>
                                            <asp:BoundField DataField="NAME_OF_PARTNER" HeaderText="Partner Name" />
                                            <asp:BoundField DataField="Partner_CODE" HeaderText="PartnerId" Visible="false" />
                                            <asp:BoundField DataField="Area_NAME" HeaderText="Area" 
                                                HeaderStyle-Width="25%" >
                                                <HeaderStyle Width="25%" />
                                            </asp:BoundField>
                                            <asp:BoundField 
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend