Click here to Skip to main content
15,890,579 members
Home / Discussions / C#
   

C#

 
AnswerRe: Question with converting double to long Pin
#realJSOP18-Mar-10 9:46
mve#realJSOP18-Mar-10 9:46 
AnswerRe: Question with converting double to long Pin
Luc Pattyn18-Mar-10 9:55
sitebuilderLuc Pattyn18-Mar-10 9:55 
GeneralRe: Question with converting double to long Pin
Richard MacCutchan18-Mar-10 10:34
mveRichard MacCutchan18-Mar-10 10:34 
GeneralRe: Question with converting double to long Pin
Alaric_18-Mar-10 10:35
professionalAlaric_18-Mar-10 10:35 
GeneralRe: Question with converting double to long Pin
Luc Pattyn18-Mar-10 11:06
sitebuilderLuc Pattyn18-Mar-10 11:06 
AnswerRe: Question with converting double to long Pin
AspDotNetDev18-Mar-10 10:53
protectorAspDotNetDev18-Mar-10 10:53 
AnswerRe: Question with converting double to long Pin
PIEBALDconsult18-Mar-10 16:22
mvePIEBALDconsult18-Mar-10 16:22 
Question(2.0) ...wanting to show/hide control within a GridView's TableCell.Controls collection. [modified] Pin
Alaric_18-Mar-10 7:57
professionalAlaric_18-Mar-10 7:57 
Hi guys/gals. ...I'll cut to the chase.

I'm working with a 2.0 GridView bound to a list of my own custom data object...i.e.:
grid.DataSource = List<Record>;


Among other data, Record has a StatusMessage property that needs to display in one of the columns and it is optionally very long. I want to maintain consistent row sizes, so I am trying to use an ItemTemplate to have the TableCell contain a label with a substring of the StatusMessage plus an optionally visible "ellipsis button" if the length of the StatusMessage is longer than the set-length substring.

(Basically, if the message is "foo", I want to display "foo" and nothing else. If the message is "foofoofoofoofoofoofoofoofoofoofoofoofoo" I want to display "foofoo [...]"

...I'm trying to find an event when the GridView is created where I have access to the controls within the TemplateField (should be 2: {asp:Label, asp:Button}) and the collection never has any contents. (examples of my attempts)

protected void grdOutput_RowCommand(object sender, GridViewCommandEventArgs e)
   {
       int _selectedIndex = int.Parse(e.CommandArgument.ToString());
       grdOutput.Rows[_selectedIndex].BackColor = System.Drawing.Color.CornflowerBlue;
       Record record = ((List<Record>)grdOutput.DataSource)[_selectedIndex];
       grdErrors.DataSource = GetNotificationErrors(record.NotificationID);
       grdErrors.DataBind();
   }
   protected void grdOutput_RowDataBound(object sender, GridViewRowEventArgs e)
   {
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
           LinkButton _rowClickButton = (LinkButton)e.Row.Cells[3].Controls[0];
           string _script = ClientScript.GetPostBackClientHyperlink(_rowClickButton, "");
           e.Row.Attributes["onclick"] = _script;
           e.Row.Cells[2].CssClass = "expandoButton";
           e.Row.Cells[2].Controls[1].Visible = true; //Controls has no contents
       }
   }
   protected void grdOutput_RowCreated(object sender, GridViewRowEventArgs e)
   {
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
           Record record = (Record)e.Row.DataItem;
           if (record != null)
           {
               TableCell cell = e.Row.Cells[2];
               cell.Text = record.StatusMessage;
               cell.Controls[1].Visible = true;  //Controls has no contents
               if (record.StatusMessage.Length > 50)
               {
                   cell.Text = record.StatusMessage.Substring(0, 50);
               }
               cell.CssClass = "expandoButton";
               cell.BackColor = System.Drawing.Color.Orange;
           }

       }
   }

   protected void grdOutput_PreRender(object sender, EventArgs e)
   {
       GridView output = (GridView)sender;

       foreach (GridViewRow row in output.Rows)
       {
           row.Cells[2].Controls[1].Visible = false; //Controls has no contents
           if (row.Cells[2].Text.Length > 50)
           {
               row.Cells[2].Text = ((Record)row.DataItem).StatusMessage.Substring(0, 50);
               row.Cells[2].Controls[1].Visible = true; //Controls has no contents
           }
       }
   }<div class="signature"><div class="modified">modified on Thursday, March 18, 2010 2:25 PM</div></div>

AnswerRe: (2.0) ...wanting to show/hide control within a GridView's TableCell.Controls collection. Pin
Alaric_18-Mar-10 10:44
professionalAlaric_18-Mar-10 10:44 
QuestionProblem running deployed application online only - C# .NET 3.51 Pin
Jon Braunsma18-Mar-10 7:42
Jon Braunsma18-Mar-10 7:42 
Questiondegrees to MILS Pin
v17.poornima18-Mar-10 6:47
v17.poornima18-Mar-10 6:47 
AnswerRe: degrees to MILS Pin
PIEBALDconsult18-Mar-10 6:58
mvePIEBALDconsult18-Mar-10 6:58 
GeneralRe: degrees to MILS Pin
Luc Pattyn18-Mar-10 8:16
sitebuilderLuc Pattyn18-Mar-10 8:16 
AnswerRe: degrees to MILS Pin
Keith Barrow18-Mar-10 7:48
professionalKeith Barrow18-Mar-10 7:48 
AnswerRe: degrees to MILS Pin
Saksida Bojan18-Mar-10 7:51
Saksida Bojan18-Mar-10 7:51 
AnswerRe: degrees to MILS [modified] Pin
Dr.Walt Fair, PE18-Mar-10 8:09
professionalDr.Walt Fair, PE18-Mar-10 8:09 
GeneralRe: degrees to MILS Pin
Luc Pattyn18-Mar-10 8:16
sitebuilderLuc Pattyn18-Mar-10 8:16 
GeneralRe: degrees to MILS Pin
Dr.Walt Fair, PE18-Mar-10 8:30
professionalDr.Walt Fair, PE18-Mar-10 8:30 
GeneralRe: degrees to MILS Pin
Luc Pattyn18-Mar-10 8:41
sitebuilderLuc Pattyn18-Mar-10 8:41 
GeneralRe: degrees to MILS Pin
v17.poornima19-Mar-10 3:56
v17.poornima19-Mar-10 3:56 
GeneralRe: degrees to MILS Pin
Dr.Walt Fair, PE19-Mar-10 4:39
professionalDr.Walt Fair, PE19-Mar-10 4:39 
QuestionHow to build a trial version setup using C#.net Pin
eswar pothula18-Mar-10 5:57
eswar pothula18-Mar-10 5:57 
AnswerRe: How to build a trial version setup using C#.net Pin
Saksida Bojan18-Mar-10 7:15
Saksida Bojan18-Mar-10 7:15 
Generalc# Pin
akshatak18-Mar-10 5:46
akshatak18-Mar-10 5:46 
GeneralRe: c# Pin
Keith Barrow18-Mar-10 6:52
professionalKeith Barrow18-Mar-10 6:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.