locked
How To Data Split and show in gridview Columns RRS feed

  • Question

  • User-1832003983 posted

    This is my Database Columan Name(Desription) and Data Stored

    [Warehouse Charges fixd ;Insurance Charges ;Laber Chargses extra ;]

    This data seprated by(";").

    and Thsi is my Gridview Coading.

    {
    SQLDT.Rows.Add();
    SQLDT.Rows[0]["SrNo"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["SrNo"].ToString();
    SQLDT.Rows[0]["Description"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["Description"].ToString();
    SQLDT.Rows[0]["HSNCODE_FK"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["HSNCODE_FK"].ToString();
    SQLDT.Rows[0]["Rate"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["Rate"].ToString();
    SQLDT.Rows[0]["QTY"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["QTY"].ToString();
    SQLDT.Rows[0]["Amount"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["Amount"].ToString();
    SQLDT.Rows[0]["SGSTPER"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["SGSTPER"].ToString();
    SQLDT.Rows[0]["SGSTAMT"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["SGSTAMT"].ToString();
    SQLDT.Rows[0]["CGSTPER"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["CGSTPER"].ToString();
    SQLDT.Rows[0]["CGSTAMT"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["CGSTAMT"].ToString();
    SQLDT.Rows[0]["IGSTPER"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["IGSTPER"].ToString();
    SQLDT.Rows[0]["IGSTAMT"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["IGSTAMT"].ToString();
    SQLDT.Rows[0]["TotalAmount"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["TotalAmount"].ToString();

    }

    dr = SQLDT.NewRow();

    GRDINVOICEP.DataSource = SQLDT;

    GRDINVOICEP.DataBind();

    How to Split The Data in Description Columans

    pls Help Me

    Regards 

    Pankaj

    Thursday, March 29, 2018 1:55 PM

All replies

  • User1623409651 posted

    Hi see below example of spilt the string

    string s = "a,b, b, c";
    string[] values = s.Split(',');
    for(int i = 0; i < values.Length; i++)
    {
       values[i] = values[i].Trim();
    }

    https://www.c-sharpcorner.com/uploadfile/mahesh/split-string-in-C-Sharp/

    using sql server 

    https://www.aspsnippets.com/Articles/Split-and-convert-Comma-Separated-Delimited-String-to-Table-in-SQL-Server.aspx

    Friday, March 30, 2018 4:33 AM
  • User-1832003983 posted

    How to use gridview ? Sir

    pls Help me

    Thursday, April 12, 2018 5:18 AM
  • User-1832003983 posted

    try
    {
    DataTable SQLDT = new DataTable();
    DataRow dr;
    SqlDataAdapter da = new SqlDataAdapter();
    SQLDT.TableName = "TBL_INVOICE";
    SQLDT.Columns.Add("SrNo", Type.GetType("System.String"));
    SQLDT.Columns.Add("Description", Type.GetType("System.String"));
    SQLDT.Columns.Add("HSNCODE_FK", Type.GetType("System.String"));
    SQLDT.Columns.Add("Rate", Type.GetType("System.String"));
    SQLDT.Columns.Add("QTY", Type.GetType("System.String"));
    SQLDT.Columns.Add("Amount", Type.GetType("System.String"));
    SQLDT.Columns.Add("SGSTPER", Type.GetType("System.String"));
    SQLDT.Columns.Add("SGSTAMT", Type.GetType("System.String"));
    SQLDT.Columns.Add("CGSTPER", Type.GetType("System.String"));
    SQLDT.Columns.Add("CGSTAMT", Type.GetType("System.String"));
    SQLDT.Columns.Add("IGSTPER", Type.GetType("System.String"));
    SQLDT.Columns.Add("IGSTAMT", Type.GetType("System.String"));
    SQLDT.Columns.Add("TotalAmount", Type.GetType("System.String"));
    SQLDT.Columns.Add("TotalAmountIncludingTAX", Type.GetType("System.String"));


    {
    SQLDT.Rows.Add();
    SQLDT.Rows[0]["SrNo"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["SrNo"].ToString();
    SQLDT.Rows[0]["Description"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["Description"].ToString();
    SQLDT.Rows[0]["HSNCODE_FK"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["HSNCODE_FK"].ToString();
    SQLDT.Rows[0]["Rate"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["Rate"].ToString();
    SQLDT.Rows[0]["QTY"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["QTY"].ToString();
    SQLDT.Rows[0]["Amount"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["Amount"].ToString();
    SQLDT.Rows[0]["SGSTPER"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["SGSTPER"].ToString();
    SQLDT.Rows[0]["SGSTAMT"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["SGSTAMT"].ToString();
    SQLDT.Rows[0]["CGSTPER"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["CGSTPER"].ToString();
    SQLDT.Rows[0]["CGSTAMT"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["CGSTAMT"].ToString();
    SQLDT.Rows[0]["IGSTPER"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["IGSTPER"].ToString();
    SQLDT.Rows[0]["IGSTAMT"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["IGSTAMT"].ToString();
    SQLDT.Rows[0]["TotalAmount"] = XINV.Tables["TBL_INVOICEP"].Rows[0]["TotalAmount"].ToString();

    }

    dr = SQLDT.NewRow();

    GRDINVOICEP.DataSource = SQLDT;

    GRDINVOICEP.DataBind();
    }
    catch (Exception ex)
    {
    ex.Message.ToString();
    }

    Gird Veiw data show but 

    1;2;3 this format(How to Seprate?)

    pls Help me Sir

    Thursday, April 12, 2018 5:22 AM
  • User1623409651 posted

    Hi,

    Gird Veiw data show but 
    
    1;2;3 this format(How to Seprate?)

    Which one field kindly mention the field which you want to spilt ?

    Thanks

    Thursday, April 12, 2018 5:28 AM