Click here to Skip to main content
15,887,386 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I get value like "ABC~12"...I want to split it take it only "ABC"...the whole thing i need in gridview itemtemplate..how to split it in gridview itemtemplate & take only "ABC"???
Posted

1 solution

User GridView Row databound event:
C#
protected void GVSample_RowDataBound(object sender, GridViewRowEventArgs e)
        {   //Get data row view
            DataRowView drview = e.Row.DataItem as DataRowView;
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //Find textbox control
                TextBox txtname = (TextBox)e.Row.FindControl("txtName");
                String text = "ABC~12"
                txtname.Text = text.Split('~')[0].ToString();
            }
        }
 
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