Click here to Skip to main content
15,921,028 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: "The state information is invalid for this page or might be corrupted." Pin
Mr.Sam30-Oct-07 7:30
Mr.Sam30-Oct-07 7:30 
GeneralRe: "The state information is invalid for this page or might be corrupted." Pin
Saksida Bojan30-Oct-07 7:40
Saksida Bojan30-Oct-07 7:40 
QuestionHow to get/set session variables in httpModule? Pin
Rip Kirby30-Oct-07 6:31
Rip Kirby30-Oct-07 6:31 
AnswerRe: How to get/set session variables in httpModule? Pin
Jon Sagara30-Oct-07 8:57
Jon Sagara30-Oct-07 8:57 
AnswerRe: How to get/set session variables in httpModule? Pin
N a v a n e e t h30-Oct-07 19:17
N a v a n e e t h30-Oct-07 19:17 
GeneralRe: How to get/set session variables in httpModule? Pin
Rip Kirby30-Oct-07 23:02
Rip Kirby30-Oct-07 23:02 
QuestionASP.Net, Stop/Start windows scheduled jobs Pin
Al Rosciano30-Oct-07 6:29
Al Rosciano30-Oct-07 6:29 
QuestionDatalist not rebinding Pin
acodman30-Oct-07 6:17
acodman30-Oct-07 6:17 
Hi Guys,

can anyone help me with with my code. i have a datalist and some textfield with a button to submit. once submitted, the page should rebind it'self, but it seems not working. see my code below:

using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;



public partial class mssgboard_Messageboard : System.Web.UI.Page
{
SqlConnection datalistconn;
SqlDataReader datalistdr;
SqlCommand datalistcmd;

SqlConnection conn;
//SqlDataReader dr;
SqlCommand cmd;

void Bindata()
{
try
{
datalistconn = new SqlConnection(ConfigurationManager.ConnectionStrings["CmsDb"].ConnectionString);
datalistcmd = new SqlCommand("SELECT nam,phone_number,email,comments FROM tbl_mssgboard ORDER BY refid DESC", datalistconn);
datalistconn.Open();
datalistdr = datalistcmd.ExecuteReader();
if (datalistdr.Read())
{
DataList1.DataSource = datalistdr;
DataList1.DataBind();


}
}
catch (Exception exc)
{
Response.Write(exc.Message);
}
finally
{
datalistdr.Close();
datalistconn.Close();
}

}

protected void Page_Load(object sender, EventArgs e)
{


Bindata();


}
protected void btnsubmit_Click(object sender, EventArgs e)
{
try
{
conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CmsDb"].ConnectionString);
cmd = new SqlCommand("INSERT INTO tbl_mssgboard(nam,phone_number,email,comments) VALUES(@nam,@phone_number,@email,@comments)", conn);
cmd.Parameters.Add("@nam", SqlDbType.VarChar,50);
cmd.Parameters.Add("@phone_number", SqlDbType.VarChar, 50);
cmd.Parameters.Add("@email", SqlDbType.VarChar, 50);
cmd.Parameters.Add("@comments", SqlDbType.VarChar, 50);


cmd.Parameters["@nam"].Value = this.txtname.Text;
cmd.Parameters["@phone_number"].Value = this.txtphone.Text;
cmd.Parameters["@email"].Value = this.txtemail.Text;
cmd.Parameters["@comments"].Value = this.txtcomments.Text;
conn.Open();
cmd.ExecuteNonQuery();

this.txtname.Text = "";
this.txtphone.Text= "";
this.txtemail.Text = "";
this.txtcomments.Text = "";
Bindata();
}
catch (Exception exc)
{
Response.Write(exc.Message);
}
finally
{

conn.Close();

}
}
}


i will appreciate your professional expertise.
thanks
AnswerRe: Datalist not rebinding Pin
Saksida Bojan30-Oct-07 7:22
Saksida Bojan30-Oct-07 7:22 
QuestionWebService with ASP.net ERROR Pin
kendo1730-Oct-07 5:42
kendo1730-Oct-07 5:42 
AnswerRe: WebService with ASP.net ERROR Pin
Paddy Boyd30-Oct-07 5:52
Paddy Boyd30-Oct-07 5:52 
Questionhow to unlock design mode in debugging Pin
Farhad Eft30-Oct-07 4:47
Farhad Eft30-Oct-07 4:47 
AnswerRe: how to unlock design mode in debugging Pin
pmarfleet30-Oct-07 5:57
pmarfleet30-Oct-07 5:57 
Questionhelp needed developing chat application ( with notification server) Pin
sarat12in30-Oct-07 4:43
sarat12in30-Oct-07 4:43 
AnswerRe: help needed developing chat application ( with notification server) Pin
Christian Graus30-Oct-07 11:09
protectorChristian Graus30-Oct-07 11:09 
QuestionParsing URL for subdomain only Pin
csinva30-Oct-07 4:39
csinva30-Oct-07 4:39 
QuestionProblem with DataReader............ Pin
Deepak Nigam30-Oct-07 3:30
Deepak Nigam30-Oct-07 3:30 
AnswerRe: Problem with DataReader............ Pin
ToddHileHoffer30-Oct-07 3:33
ToddHileHoffer30-Oct-07 3:33 
AnswerRe: Problem with DataReader............ Pin
Herman<T>.Instance30-Oct-07 3:50
Herman<T>.Instance30-Oct-07 3:50 
AnswerRe: Problem with DataReader............ Pin
Abhijit Jana30-Oct-07 3:52
professionalAbhijit Jana30-Oct-07 3:52 
QuestionHow to access one Control from master page using Javascript Pin
VenkataRamana.Gali30-Oct-07 3:21
VenkataRamana.Gali30-Oct-07 3:21 
AnswerRe: How to access one Control from master page using Javascript Pin
ToddHileHoffer30-Oct-07 3:37
ToddHileHoffer30-Oct-07 3:37 
QuestionDocumnetation generator Pin
samerh30-Oct-07 3:07
samerh30-Oct-07 3:07 
AnswerRe: Documnetation generator Pin
Abhijit Jana30-Oct-07 3:14
professionalAbhijit Jana30-Oct-07 3:14 
GeneralRe: Documnetation generator Pin
samerh30-Oct-07 3:30
samerh30-Oct-07 3:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.