|
What is this Arr and getvalue plz help detaily
|
|
|
|
|
Sun Rays wrote: ArrayListarr = new ArrayList(); // declare in page load
ArrayList arr = new ArrayList();
Sun Rays wrote: arr.Add("get value");
getvalue is value which you are fetching from gridview's selected row.
As you want to add value from grdview.selected row's cell's value.
Thanks,
Sun Rays
To get something you must have to try once.
My Articles
|
|
|
|
|
protected void GrdChatUsers_SelectedIndexChanged(object sender, EventArgs e)
{
int i = GrdChatUsers.Rows.Count;
for (int j = 0; j < i; j++)
{
//string Arr = GrdChatUsers.Rows[j].Cells[2].Text;
ArrayList ar = new ArrayList();
if (ViewState["Arr"] != null)
{
ar = (ArrayList)ViewState["Arr"];
ar.Add(GrdChatUsers.Rows[j].Cells[2].Text);
ViewState["Arr"] = ar;
}
}
}
I tried the above code but i didnt get the value plz solve it
|
|
|
|
|
SreejithAchutan wrote: protected void GrdChatUsers_SelectedIndexChanged(object sender, EventArgs e)
{
int i = GrdChatUsers.Rows.Count;
for (int j = 0; j < i; j++)
{
//string Arr = GrdChatUsers.Rows[j].Cells[2].Text;
ArrayList ar = new ArrayList();
if (ViewState["Arr"] != null)
{
ar = (ArrayList)ViewState["Arr"];
ar.Add(GrdChatUsers.Rows[j].Cells[2].Text);
ViewState["Arr"] = ar;
}
}
}
Hi,
do below changes.
event must be below...
protected void GrdChatUsers_SelectedIndexChanging(object sender, EventArgs e)<br />
{<br />
<br />
ArrayList ar;<br />
if (ViewState["Arr"] != null)<br />
{<br />
ar = (ArrayList)ViewState["Arr"];<br />
}<br />
else<br />
{<br />
ar = new ArrayList();<br />
}<br />
ar.Add(GrdChatUsers.Rows[e.NewSelectedIndex].Cells[2].Text);<br />
ViewState["Arr"] = ar;<br />
}<br />
Hope it will help you...
Thanks,
Sun Rays
To get something you must have to try once.
My Articles
|
|
|
|
|
in the database..in a table..........i have a field named "username".....
in the username. field "Ramesh" is there ..
i want to calculate that how many times "ramesh" is there in the username field..using sql
|
|
|
|
|
This must be in SQL Forum, this has nothing to do with ASP.NET.
Select count(*) from table where username = 'ramesh'
SG
Cause is effect concealed. Effect is cause revealed.
|
|
|
|
|
Hi! All
I ve to add controls dynamically to a webpage; so i did but i 've to initiate their events as well. I add events to them but their events are not called (such as if newControl.SelectedIndexChaged += new EventArgs(newControl_SelectedIndexChanged). but it not works it can not called to it handler.
So,
what should i do to activate their events. any suggestion will be anticipated.
Thanks in advance.
|
|
|
|
|
Hi,
do this.
DropDownList ddlMy = new DropDownList();<br />
ddlMy.Items.Add("test");<br />
ddlMy.Items.Add("test1");<br />
ddlMy.Items.Add("test2");<br />
ddlMy.Items.Add("test3");<br />
ddlMy.Items.Add("test4");<br />
ddlMy.AutoPostBack = true;<br />
ddlMy.SelectedIndexChanged += new EventHandler(ddlMy_SelectedIndexChanged);<br />
this.form1.Controls.Add(ddlMy);<br />
And create one event for that.
void ddlMy_SelectedIndexChanged(object sender, EventArgs e)<br />
{<br />
lblMyDDL.Text =((DropDownList)sender).SelectedItem.Text;
}
Thanks,
Sun Rays
To get something you must have to try once.
My Articles
|
|
|
|
|
Thanks 2 all; for reply
I already did, only thing i missed to set autopostback = true of a control.
Thanks again.
Reagard
|
|
|
|
|
Post your code
please don't forget to vote on the post that helped you.
|
|
|
|
|
|
Is the code to add controls dynamically is written in Page_Init or Page_Load? If you have written the code in the Page_load then it will not behave as you expect it to...and the controls won't participate in the viewState too.
- Regards - JON Life is not measured by the amount of breaths we take, but by the moments that take our breath away.
|
|
|
|
|
Hello all,
I have developed a web application in ASP.Net using C# with login credentials.
I am getting following problem with it.....
I am logging in as user "abc" from one computer in network, its working fine. At the same time, i m logging in as different user say "xyz" on other computer. After this, when i refreshes my "abc" user's page it shows all contents of "xyz" user and hence automatically expires session of "abc".
I am not getting where the actual problem is, please anyone of u can help me with this?
Thanks,
Nagendra.
|
|
|
|
|
nagendrathecoder wrote: After this, when i refreshes my "abc" user's page it shows all contents of "xyz" user and hence automatically expires session of "abc".
The session won't be expiring. It's your programming mistake. Can we have a look into your code ?
|
|
|
|
|
Sure, this is Login Page code.....
private void BtnGo_Click(object sender, System.EventArgs e)
{
Label1.Visible=false;
bool persistcookie=true;
if(ValidateUser(TextBox1.Text,TextBox2.Text))
{
//string globalstrConn="Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=iMedia;Integrated Security=SSPI;";
Session["UserName"]=TextBox1.Text;
//This will store the username of the user in this session variable
// We can retrieve this username on different pages by using following code.
// string str=Convert.ToString(Session["UserName"]);
FormsAuthenticationTicket tkt;
string cookiestr;
HttpCookie ck;
tkt=new FormsAuthenticationTicket(1,TextBox1.Text,System.DateTime.Now,System.DateTime.Now.AddMinutes(Convert.ToInt32(ConfigurationSettings.AppSettings["timeout"])),persistcookie,"Your Custom Date");
cookiestr=FormsAuthentication.Encrypt(tkt);
ck=new HttpCookie(FormsAuthentication.FormsCookieName,cookiestr);
if(persistcookie)
ck.Expires =tkt.Expiration;
ck.Path =FormsAuthentication.FormsCookiePath;
Response.Cookies.Add(ck);
string strredirect;
strredirect=Request["ReturnUrl"];
if(strredirect==null)
strredirect="login.aspx";
Response.Redirect(ConfigurationSettings.AppSettings["defaultpage"],true);
}
else
{
Label1.Text="Invalid Credentials!";
Label1.Visible=true;
// Response.Redirect("login.aspx",true);
}
}
|
|
|
|
|
How to make a dropdownlist to be selected based on HTML anchor tag selection
|
|
|
|
|
You can access any control in code behind by adding runat='server'
Not sure how you want to select a dropdown based on a link tho. You probably want to do whatever you're doing in script, not code behind.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
How to access the HTML controls in code behind using asp.net with c#
|
|
|
|
|
Right click on the HTML control and choose "Run at server" or add Runat=Server attribute manually to your HTML controls tag.
|
|
|
|
|
You have make the html control a server control in order to access it on server side. Just make them runat=server and assign a ID to that control.
Apurva Kaushal
|
|
|
|
|
In a registration page after clicking submit button when we are pressing F5(refresh button) it again fires the submit button events(code).why?plz tell me the reason.and also how i can prevent this situation.
thanks in adv.
Sujit
|
|
|
|
|
Posted data will be kept in browsers cache, and when refresh is pressed, same data will be posted again which will invoke buttons event. To prevent this
1- After insertion to database, redirect to the same page. This will remove posted data from browser's cache
2 - Before insertion do a checking to verify that data is not duplicating.
|
|
|
|
|
thanx for yours help.
But i hv still 1 problem.after redirect the page Ispostback property fires again but i don't need this.bcz i hv some logic in Ispostback which will fires only once.
thn how can i avoid this Ispostback.
Sujit
|
|
|
|
|
|
Michael Sync wrote: What I did in my project is that if the user clicks the submit button, I disable this button during the processing time.
But after the process is over and in case you are there in the same page and then refresh button is clicked again the same problem will occur.
Apurva Kaushal
|
|
|
|