|
|
I have a databound GridView that I populate from the codebehind and the data appears correctly on the form. The user has the option to add another row to the GridView from data selected on a popup window. I successfully added this new row to the GridView using jQuery. Here is the code I used to copy the last row in the GridView, and then I updated the last row cell by cell after that.
$('#<%=grdUsers.ClientID%> tbody>tr:last').clone(true).insertAfter('#<%=grdUsers.ClientID%> tbody>tr:last');
$('#<%=grdUsers.ClientID%> tbody>tr:last').find("td:nth-child(1)").text(strFirstName);
$('#<%=grdUsers.ClientID%> tbody>tr:last').find("td:nth-child(2)").text(strLastName);
Here is how I am trying to loop through rows in codebehind:
foreach (GridViewRow row in grdUsers.Rows)
{
}
The problem is that when I try to access the contents of the GridView from the codebehind after postback, I do not have access to the row I added via jQuery on the client side. The row does not appear in the grdUsers.Rows collection.
What is the best way to get this data over to the server side so I can access it and save the data in session using my standard save routines?
|
|
|
|
|
You don't seem to understand how a ASP.NET control functions. During a postback the controls are recreated and populated from viewstate, if used, to retrieve any updates that have been made. When a row is added to dynamically to a GridView the server-side processes know nothing about it, it isn't in the viewstate. That is why it is not available to you. GridView does a feature to allow new rows to be added without needing javaScript to do so.
I know the language. I've read a book. - _Madmatt
modified on Monday, July 19, 2010 4:20 PM
|
|
|
|
|
hi all,
I am using document.getElementById("controlname").click() in javascript.It is working fine in IE but not working in firefox.Please tell how it can be corrected.
|
|
|
|
|
What kind of control is it? Are you sure that the getElementById call is returning an object?
|
|
|
|
|
hi,
yes document.getElementById("buttonid") is returning an object in both IE and Firefox.The problem only is that i had to fire the click event of the button using the click event in the javascript which is i think is not supported by FF.
|
|
|
|
|
document.getElementById("<%=ContolName.ClientID%>");
|
|
|
|
|
Use a library, like JQuery, that has cross browser support rather than trying to deal with multiple browser issues.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi All,
I want to update the table using select statement .
suppose i have table A which contains one column id and salary
Update A SET salary = (SELECT id FROM A);
when i am doing using above method i am getting following error
you can not specify target table A for update in from clause
is it possible to do using above way or else can u guys suggest other way.
Thanks,
amit
|
|
|
|
|
|
hi Amit Patel1985,
Please from next time post general database related queries in General Database[^] section.
So that interested users will give you quick and
better answer.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Hi All,
I am getting this error above error when i am using my sql server 4.1 with 6.1.3 connector. it run for some time after that it gives above error
thanks ,
amit
|
|
|
|
|
So, did you try this[^] ?
..Go Green..
|
|
|
|
|
I want to show a tree view which will show 3 categories. For example product categories. There will be a main category than a child/sub categories than another child of child or sub sub categories. But i dont know how to do that.What will be the database structure? I'm using mysql and language C#.
|
|
|
|
|
Try thins one[^].
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
|
hi,
we developed two forms.asp x with Dynamic Controls,First form has one Dynamic button_Open ,this button has Click event ,through button_Open_Click event we need to open second form with dynamic controls through
(window.open()),window opening but forms.asp x not displaying controls and Second form overwriting on first form ,we added code for Dynamic Controls in both pages Page_PreInit event.Please suggest me to do the better way to maintain state of control both pages.
|
|
|
|
|
Can you elaborate your question along with some sample code
|
|
|
|
|
hi,
we are creating dynamic controls (Button,Text Box,etc..)on form, we write code for dynamic Controls in Page_preInit event and this form has all dynamic controls .
in Dyanamic Button Click event we need to open new window with dynamic controls.it is opening same window not in another popup window.
Button_Click Event code below
string scriptOne = "";
scriptOne += "var w = 700;";
scriptOne += "var h = 300;";
scriptOne += "var left = (screen.width/2)-(w/2);";
scriptOne += "var top = (screen.height/2)-(h/2);";
scriptOne += "window.open('DynamicSearchControl.aspx','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);";
this.Page.ClientScript.RegisterStartupScript(this.GetType(),"Privilge", scriptOne,true);
|
|
|
|
|
hi,
My problem Solved ,so don't waste your time on my issue.
|
|
|
|
|
Hi,
i am upload document in particular folder.
this folder only access admin only.
so i want make protect that folder.
How will give folder permission in runtime.
please give me ur valuable feedback..
Yours,
KaNNaN
-----------------------------------------------------------------
"Success is When Ur Signature Becomes An Autograph"
|
|
|
|
|
|
Can anyone tell me how to apply Page_Error in ASP.NET?
I have written the following code in some.aspx.cs file.
protected void Button1_Click(object sender, EventArgs e)
{
int[] a=new int[5];
a[5] = 0;
}
public void Page_Error(object sender, EventArgs e)
{
Response.Write("Error occured...");
}
Where I am making mistake? Please help....
NEHA GUPTA
|
|
|
|
|
Ok you implemented the page error event to write a string to output stream. It will fire whenever the page encounter an error. So what is your problem? What you want to attain?
|
|
|
|
|
I am getting an exception instead of getting response on the web page.
NEHA GUPTA
|
|
|
|