Click here to Skip to main content
15,902,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In the Cell of grid i am having data

SR-233546/assigned , SR-656756/New

What i want the data along with slash should not appear in cell It shuold appear this way
SR-533546 so how can i trim the data.

second thing is on mouse hover it should show that following id"SR-53346" is in process or isCompleted

can you guide me what should i code?
Posted
Comments
[no name] 17-Sep-13 5:27am    
"can you guide me what should i code", sure... learn about the String class and how to create a tooltip.

1 solution

Hi, you can achieve it in RowDataBound event of gridview.
C#
protected void YourGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
      if (e.Row.RowType == DataControlRowType.DataRow)
      {
            // suppose you are storing your required value in label.
            Label lbl = (Label)e.Row.FindControl("LabelID");
            string[] value = lbl.Text.Split('/');
            if(value.Length > 0)
            {
                  lbl.Text = value[0];
            }
            lbl.ToolTip = your value; //in process or iscompleted
      }
}


Hope it helps you.
Thanks.
 
Share this answer
 
Comments
hira_1 17-Sep-13 6:53am    
i tried see :It is a link button.. I did this:

string value = LnkMSid.Text.Split('/').ToString();

if (value.Length > 0) {

LnkMSid.Text = value[0].ToString(); }

i got this out put S
Harshil_Raval 17-Sep-13 6:55am    
So, you got currect output?
hira_1 17-Sep-13 7:13am    
No :( ... output should be.. SR-1212323 or IN-65877678 ... these are actually the id's
Harshil_Raval 17-Sep-13 7:18am    
Hi,
string value = LnkMSid.Text.Split('/').ToString();
if (value.Length > 0) {
LnkMSid.Text = value[0].ToString();
}
You have posted this code in comment. But this is not right. It should be
string[] value = LnkMSid.Text.Split('/');
if (value.Length > 0) {
LnkMSid.Text = value[0].ToString();
} Check by implementing this code. It should give you your desire result. Say for example your string="SR-1212323/assigned". Then after split, string value will be SR-1212323.
hira_1 17-Sep-13 7:45am    
ok i am checking it agian
Thank you :)

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