|
protected void grdOutput_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Record record = (Record)e.Row.DataItem;
if (record.StatusMessage.Length > 50 )
{
((Label)e.Row.FindControl("lblStatusMessage")).Text = record.StatusMessage.Substring(0, 50);
}
}
The markup
<form id="form1" runat="server">
<div>
<asp:GridView ID="grdOutput" runat="server" Width="895px" AllowPaging="False"
AutoGenerateColumns="False" onrowcommand="grdOutput_RowCommand"
onrowdatabound="grdOutput_RowDataBound" BackColor="AntiqueWhite"
onrowcreated="grdOutput_RowCreated">
<Columns>
<asp:BoundField HeaderText="NotificationID" DataField="NotificationID" Visible="true"/>
<asp:BoundField HeaderText="Notifier" DataField="Notifier" visible="true" />
<asp:TemplateField HeaderText="StatusMessage" Visible="true">
<ItemTemplate>
<asp:Label ID="lblStatusMessage" runat="server" Text='<%# Bind("StatusMessage") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:ButtonField Text="RowClick" CommandName="RowClick" visible="false"/>
</Columns>
<FooterStyle BackColor="SlateGray" />
<HeaderStyle BackColor="SlateGray" />
<AlternatingRowStyle BackColor="LightSteelBlue" />
</asp:GridView>
</div>
<div style="background-color: Gray; width:800px; Overflow:auto;">
<asp:ListBox ID="lbxOutput" runat="server" Height="31px" Width="795px" />
<asp:TextBox ID="hdnActiveRow" Visible="true" runat="server" />
</div>
</form>
e.Row.FindControl("lblStatusMessage") is returning null and I have absolutely no idea why. Any clue?
"I need build Skynet. Plz send code"
|
|
|
|
|
d'oh.
...if you're going to try and access a control in a GridView, don't do this in RowCreated lol:
Record record = (Record)e.Row.DataItem;
TableCell cell = e.Row.Cells[2];
cell.Text = record.StatusMessage;
(The code was prototype code that I had commented out. I must have accidentally had it selected when I uncommented code that surrounded it)
...but can anyone explain why the Controls collection is mutilated when accessing the cell directly?
"I need build Skynet. Plz send code"
|
|
|
|
|
This happens because when you use a control(here a label) inside another control which implements "INamingContainer"( here GridView) , the ID generated becomes diferrent ( you can see that generated ID is an hierarchical name ) hence with provided ID ( here lblStatusMessage) you dont get that control.
FindControl does not locate that only because the ID value you have provided has been changed at runtime.
Thanks,
Arindam D Tewary
|
|
|
|
|
So assigning the cell Text as in...
Record record = (Record)e.Row.DataItem;
TableCell cell = e.Row.Cells[2];
cell.Text = record.StatusMessage;
...causes the control that is contained in that cell to be reassigned an id? That doesn't make much sense to me, but I would love to hear more detail as to why that is the case.
Whenever I comment out my assignment "cell.Text = record.StatusMessage", the e.Row.FindControl("lblStatusMessage") lookup processed like a champ.
"I need build Skynet. Plz send code"
|
|
|
|
|
<script type="text/javascript" language="Javascript"
src="http://ajax.microsoft.com/ajax/jQuery/jquery-1.3.2.min.js"></script><script type='text/javascript'>
if (typeof jQuery == 'undefined') {
document.write(unescape("%3Cscript
src='/script/JS/jquery-1.3.2.min.js' type='text/javascript' %3E%3C/script%3E"));
}
I found above code in CP home page, just want to know is there any benefit referring the jQuery framework from microsoft website at the first place?
Regards,
Prakash Kalakoti
|
|
|
|
|
JQuery has nothing to do with Microsoft, asp.net.
'jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript."
http://jquery.com/[^]
I would suggest doing a little research
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Mark, sorry if the question was not clear. I know jQuery and using it from last 2 years, actually I want to ask why the jQuery file is referenced from Microsoft website instead of a local js reference.
In the code it is checked that if the file in not available at MS site then load it from a local path. Do we get any benefit doing this?
Regards,
Prakash Kalakoti
|
|
|
|
|
Two reasons could be Consistency, the same version can be referenced. Cache, the js file could be cached by ajax.com.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks, caching seems to be more appropriate reason to me.
Regards,
Prakash Kalakoti
|
|
|
|
|
I forgot about this.
http://www.asp.net/ajaxlibrary/cdn.ashx[^]
"By taking advantage of the Microsoft Ajax CDN, you can significantly improve the performance of your Ajax applications. The contents of the Microsoft Ajax CDN are cached on servers located around the world. In addition, the Microsoft Ajax CDN enables browsers to reuse cached JavaScript files for Web sites that are located in different domains."
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
any one please explain how to deploy the web pages in windows server
|
|
|
|
|
|
|
Hi,
aspx page designer don't draw child collections.
Is there someone know a workaround or a solution for this problem ?
Bye,
melnac.
|
|
|
|
|
This is an extremely vague question, you give no relevant details
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
|
may be dotnet framework 3.5 not registered with IIS
|
|
|
|
|
Hi,
I am developing Time Sheet where the user selects the date from asp calender
so that seven days will be displayed and the no.of.hours worked will be entered
Here my question is how to save the hours worked into the database.
In my databse there are columns from day1 to day31.
I like to save the hours entered into the corresponding day of database as same the days i entered in the front end.
Suppose if i enetered 8hours for day 27 i like to save 8 in day27 of database.
Please suggest me how i can do this....
Thanks & Regards
Anjani
|
|
|
|
|
So whats the problem, just update table in database
Update [tablename] set D27(your column name)=8 where [condition]
|
|
|
|
|
Its a basic sql query .what are you trying to do..!
I suggest you to read a good book..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
Your database design is not scalable. How do you differentiate between months, or years? Do you only expect this application to be used for one 31 day month, then never again?
You should store the date along with the number of hours.
CREATE TABLE TimeSheet
(
ID INT IDENTITY(1,1) NOT NULL,
Date DATETIME NOT NULL, --Or just DATE if using SQL Server 2008
Hours TINYINT NOT NULL
)
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi Guys
I am busy working on a serializer module ,and i have a quick question, lets for instance say i have a LINQ object called User, in a website I want to serialise it to a file , its marked non serializable so it will throw an exception.
Now i take that exact same object I store it in a session called "user" now if i want to call it back I simply go (User)Session[user]; and i have it back . now how does Sessions store that object so i can retrieve it back again ?
Is there maybe a way i can store this object as a byte array and recall it ?
Any help would be great
TThanx
Chona1171
Web Developer (C#), Silverlight
|
|
|
|
|
hi all,
i had been n trouble for weeks, to generate Pdf from Gridview. i tried to use iTextsharp, but not found any how to generate Pdf from HTML. Please help me. its urgent.
Thanks in Advance.
|
|
|
|
|
If you don’t want to use any 3rd party tool for the conversion then try using SSRS report (.rdl file) locally, you can host the report locally (mode=local) in your website and report viewer control will render the pdf file for you.
Regards,
Prakash Kalakoti
|
|
|
|