Click here to Skip to main content
15,896,502 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
C#
using System;
using System.Collections;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OracleClient;
using System.Data;
using System.Collections.Generic;
using System.Linq;

public partial class page_gridview : System.Web.UI.Page
{
    string strcon = ConfigurationManager.ConnectionStrings["oracle"].ConnectionString;
    SqlDataSource sdc = null;
    string strselect = "select customer_name,product,quantity,price,date_info from db_list";
    protected void page_Init(object sender, EventArgs e)
    {
        sdc = new SqlDataSource(strcon, strselect);
        sdc.ID = "sdc";
        sdc.DeleteCommand = "delete from db_list where customer_name=:p_customer_name";
        sdc.DeleteParameters.Add(new Parameter("customer_name", TypeCode.String));

        sdc.UpdateCommand = "update db_list set product=:p_product,quantity=:p_quantity,price=:p_price,date_info=:p_date_info where customer_name=:p_customer-name";
        sdc.UpdateParameters.Add(new Parameter("customer_name", TypeCode.String));
        sdc.UpdateParameters.Add(new Parameter("product", TypeCode.String));
        sdc.UpdateParameters.Add(new Parameter("quantity", TypeCode.Decimal));
        sdc.UpdateParameters.Add(new Parameter("price", TypeCode.Decimal));
        sdc.UpdateParameters.Add(new Parameter("date_info", TypeCode.DateTime));
        Form.Controls.Add(sdc);
        GridView1.DataSourceID = "sdc";         
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GridView1.DataBind();
        }

    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        DataKey key = GridView1.SelectedDataKey;
        Response.Write("Selected customer name ::"+key.Value);
    }
}


keyword not supported: 'unicode'.

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.ArgumentException: Keyword not supported: 'unicode'.

C#
Source Error: 

Line 36:         if (!IsPostBack)
Line 37:         {
Line 38:             GridView1.DataBind();
Line 39:         }
Line 40: 

Source File: d:\Rahul_doc_soft\product\page\gridview.aspx.cs    Line: 38 


i am getting error when i put the value and press submit button then i am getting error which i mension above
plese help me
give me proper solution
Posted
Updated 19-Apr-12 3:24am
v2

1 solution

Hi,

use following way to bind grid
C#
SqlDataSource DataSourecX = new SqlDataSource(); 
        DataSourecX.ConnectionString = ConfigurationManager.ConnectionStrings["oracle"].ConnectionString;;

        DataSourecX.SelectCommand = "select customer_name,product,quantity,price,date_info from db_list"; 
        DataSourecX.Select(DataSourceSelectArguments.Empty); 


        GridView1.DataSource = DataSourecX; 
        GridView1.DataBind(); 


Hope it will Help u
Best Luck
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900