thanks for yr replying, before posting my problem i tried to use the ItemDataBound event so that i can not catch my content at runtime.
MrMicrosoftvn
Posts
-
Catching the content of DataGrid at runtime -
Catching the content of DataGrid at runtimeHello, here is my source for catching the content of DataGrid: <%# DataBinder.Eval(Container.DataItem, "Thread_Content") %> and here is my code-behind:
private void Page_Load(object sender, System.EventArgs e) { ThreadsList.DataSource = CreateDataSource(); ThreadsList.DataBind(); } // The ItemCreated event (of the DataGrid control) occur when an Item is created private void ThreadsList_ItemCreated(object sender, DataGridItemEventArgs e) { if (e.Item.ItemIndex != -1) { // the Thread_Content column has the index is 2 ((DataRowView)e.Item.DataItem).Row["2"] = ((DataRowView)e.Item.DataItem).Row[2].ToString().Replace("\n", " "); } }
above is my source to catch the content of the column Thread_Content at runtime to replace any "\n" to "
" before they bind to the control so that it will make my thread content break line. And here is my problem: at the first time when loading the page (IsPostBack return false), the source work fine, it does not have any error. But when IsPostBack return true, for instance I click the delete button in DataGrid to delete a row, i get the error: "Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.", the error occur at the line: ((DataRowView)e.Item.DataItem).Row["2"] = ((DataRowView)e.Item.DataItem).Row[2].ToString().Replace("\n", "
"); That is!!! I can not understand the reason, anyone can help me, plz show me a way. Thanks a lot !!!:):) -
upload image in ASP.NEThello, i want to allow my users upload image in my site. How can i check that whether the file uploaded by users is an image or not, the dimensions is equal 15px (width = 15px; height = 15px), and the size is less than, for instance 500KB ? Thanks for yr answer.:)
-
Unicode datahello, I get a problem to have you help me. Here is it: when i create a new article and get its content to show in the browser for my users, it can be read. After that, i get it back (its content) into textarea form to edit and click the AcceptChanges button to save my changes and store it back into the database (MS SQL 2000) (the data is saved into ntext field of MSSQL). Then i get it back again to show in the browser for my user, the content is not normally and my users can not read it. Please show me some way. My content is Unicode Data (Vietnamese) and saved in ntext data type. Thanks for your answer.
-
Redirecting to another page via buttonuse window.location in your javascript to redirect
-
bind data in ASP.NETyes, i can not use "DataBind" directly to bind my data to DropDownlist in that case. Well, i will try yr way. Thanks !!!
-
bind data in ASP.NETthansk for you answer but i think you read my question carelessly. That does not solve my problem and not that i got
-
bind data in ASP.NETHello, I get a problem in my project when binding data from the DataSource. Here is it: Well, i have 2 tables as below: Categories: ============== CategoryID CategoryName Products: ============== ProductID CategoryID ProductName That is, now i would like to bind data so that i get the HTML Source like this: <
select name="Product"> NameOfFirstCategory NameOfFirstProductInTheFirstCategory NameOfSecondProductInTheFirstCategory NameOfSecondCategory NameOfFirstProductInSecondCategory NameOfSecondProductInSecondCategory
my question is that is there available control that can do that or what ASP.NET server control should i use ? and ... plz show me a code example of it. thanks a lot !!! -
Regex !!!well. the example above is just simple. That i want to do is the way that some forum had done.
-
Regex !!!yes, i want to find that whether the Regular Expression match the value of textarea to make the text be bold
-
Regex !!!hello, imagine that my textarea have the value: [b]hello[/b] now i want to "translate" it into hello to make the text be bold. How can i do that with ASP.NET ? and where should i find those Regular Expression ? Does the Snizt Forum have them ? Thanks a lot !!! :)
-
how to store a value in cookie ???thanks for your answer :) :)
-
how to store a value in cookie ???I have a login form, and when my users click on the login button to log in my site, i want to create a cookie that store UserID, UserName ... and some information of user. How can i do that in ASP.NET ??? Thus, how can i read the value when cookie is already created ??? Thanks for your answer.
-
Reference to form ???thanks for your answer. My friend give me the way to resolve that. By using Javascript, we can rewrite the action value of the form as below:
function RewriteAction() { document.Form1.action = "onepage.aspx"; }
and when the click event of the button (OnClick event) occur, the function will be called and it will do rewrite the action value. -
Reference to form ???Hello, In my CodeBehind, how can i get reference to the form tag with attritute runat="server" ???. For example, in my aspx file, i have a form below:
the question is that how can i get reference to this form to set the attritute action="onepage.aspx" at run time ? I cant do that before. Thanks for yr replying.