6
Answers

How to pass variables / infromation from one ASP page to another??

goraperas

goraperas

19y
2.7k
1
How to pass variables / infromation from one ASP page to another?? I have a page on my application where I use javascript for making several actions, and after that I would like to pass the result to a WebForm of my ASP.NET Web Application. The input variable I use in the first page is: and the string variable I have in the other WebForm is: string resultFromTheFirstPage = ?; I would like to pass the value of the input of the first page to the string variable of the WebForm. How can I refer that?? I had a look to some articles but I haven't found yet the solution, or my code doesn't work. What should I put in the tag?? Which sentence(s) should I write in the WebForm to get the info?? Thanks, goraperas
Answers (6)
1
Vulpes
NA 98.3k 1.5m 13y
Yes, getting values from data-bound comboboxes and listboxes can be tricky.

I'd try:

if (comboBox1.SelectedIndex >  -1)
{
    DataRowView drv = (DataRowView)comboBox1.SelectedItem;
    int garbr = Convert.ToInt32(drv[comboBox1.DisplayMember].ToString());
    com.Parameters.AddWithValue("@Garbr", garbr);
}
Accepted
0
I its not working by selectedValue and dataview type casting only for datatable then use following code:
string matchValue= textbox.Text;
int _id,MainId;
foreach (DataRow row in datatableobject.Rows)
{
if (row["Name"].ToString().Contains(matchValue))
{
_id = Convert.ToInt32(row["ID"]);
MainId = _id;
}
}
You can use this is for textbox also and if you want to check like search then use Contains otherwise use row["Name"].ToString()==matchValue.
If it works then give me feedback.
0
Nel
NA 713 955.3k 13y
Hi Vulpes,
Can you please help me how it would be the opposit situation?
I  have a combobox and when clicking on a datagridview row I retrieve the values of  the row in the combobox, datatimepicker.... But the combobox.selecteditem  doesn't return the correct value. Again because of the DataGridView  type.

I have

comboBox1.SelectedItem =

Convert.ToInt32(dataGridView2.SelectedRows[0].Cells[0].Value);


but it is not changing when clicking on different rows in  the datagridview.
Can you please help me?
I will post this as a new post  now.

Thanks in advance
0
Nel
NA 713 955.3k 13y
Thank you very much Vulpes:)