Showing posts with label explain. Show all posts
Showing posts with label explain. Show all posts

Saturday, March 31, 2012

Submitting seperate values from a checkbox list?

Hi there

does anyone have time to explain how to submit seperate values from my checkbox list?
I would be muchly appreciative.

so far I have the first boxes value returning, I realise it has to go in the if/foreach loop to make a value for each one but when I put my sql command in there it can't be recognized...

please help!!

-Matt

SqlCommand cmdInterest;

cmdInterest = new SqlCommand( "Insert tbl_interests ( interestID ) Values (@dotnet.itags.org.interestID) ", conform );

//check box item testing

foreach (ListItem itmInterest in chkl_interests.Items)
{

if (itmInterest.Selected){

//now I have no idea what to put here??

}
}

cmdInterest.Parameters.Add( "@dotnet.itags.org.interestID", chkl_interests.SelectedItem.Value );

conform.Open();

cmdInsert.ExecuteNonQuery();
cmdInterest.ExecuteNonQuery();

conform.Close();

You can store the variables's values in an array, and then submit it.

string[] names = new string[5];
int i = new int();

for each (ListItem itmInterest in chkl_interests.Items)

{

names[i] = chkl_interests.Items.tostring();
i++;
}

then in the pre-render event, just store the value before you submit it.

viewstate("names") = names;

to pass its value to the client do this:

response.write("<script language=""Javascript""> ")
response.write("var array[5]; ")
response.write("array = " + names + "; ")
response.write("</script>")

I dont know if this will help you, but i dont really know what do you want.

Subrotine

Hi !
Greetings to all!
Can anybody explain why we have to write "s as object, e as eventargs " in sub routine.
with advance thanx
VijayWhen using event handlers these objects are used to provide your event handler with info about the event and what object caused the event.
Hi Vijay,

s is the object which called the subroutine and
e is the arguments of the event associated with the object.

If you are using Visual Studio then try the different properties of s and e

hope this helps