|
Read the answers you have already been given and stop wasting our time.
only two letters away from being an asset
|
|
|
|
|
Ya solve the problem ,But I have a question when I have used command button in the gridview now when i
click the "Insert" for new record the linkbutton every time use the "update" action so rather then inserting new record.
what should I do?
I had debug the application and explicitly put the value then it takes but when i use routine its default takes "Update" every time.
Please look at little code for understanding.
when click on addbutton
protected void btnAdd_Click(object sender, EventArgs e)<br />
{<br />
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MYConnectionString"].ConnectionString);<br />
SqlDataAdapter da = new SqlDataAdapter("SELECT subcat_id,subcatename,description,Pid FROM Subcatagory", con);<br />
DataTable dt = new DataTable();<br />
da.Fill(dt);<br />
<br />
DataRow dr = dt.NewRow();<br />
dt.Rows.InsertAt(dr, 0);<br />
GridView1.EditIndex = 0;<br />
GridView1.DataSource = dt;<br />
GridView1.DataBind();<br />
<br />
<br />
((LinkButton)GridView1.Rows[0].Cells[5].Controls[0]).Text = "Insert";<br />
Session["operation"] = "Insert"; <br />
<br />
}<br />
<br />
When control leaves the scope it automatic use "Update"<br />
For row updating
<br />
<br />
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)<br />
{<br />
<br />
<big><br />
<br />
if (((LinkButton)GridView1.Rows[0].Cells[5].Controls[0]).Text == "Insert" || Session["operation"] == "Insert")<br />
{<br />
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MYConnectionString"].ConnectionString);<br />
SqlCommand cmd = new SqlCommand();<br />
cmd.CommandText = "INSERT INTO Subcatagory(subcatename,description,Pid) VALUES(@subcatename,@description,@Pid)";<br />
cmd.Parameters.Add("@subcatename", SqlDbType.VarChar).Value = ((TextBox)GridView1.Rows[0].Cells[2].Controls[0]).Text;<br />
cmd.Parameters.Add("@description", SqlDbType.VarChar).Value = ((TextBox)GridView1.Rows[0].Cells[4].Controls[0]).Text;<br />
cmd.Parameters.Add("@Pid", SqlDbType.Int).Value = Int32.Parse(Request.QueryString["Pid"]); <br />
cmd.Connection = con;<br />
con.Open();<br />
cmd.ExecuteNonQuery();<br />
con.Close();<br />
<br />
}<br />
else<br />
{<br />
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MYConnectionString"].ConnectionString);<br />
SqlCommand cmd = new SqlCommand();<br />
cmd.CommandText = "UPDATE Subcatagory SET subcatename=@subcatename,description=@description WHERE subcat_id=@subcat_id";<br />
cmd.Parameters.Add("@subcatename", SqlDbType.VarChar).Value = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text;<br />
cmd.Parameters.Add("@description", SqlDbType.VarChar).Value = ((TextBox)GridView1.Rows[e.RowIndex].Cells[4].Controls[0]).Text;<br />
cmd.Parameters.Add("@subcat_id", SqlDbType.Int).Value = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[1].Text);<br />
cmd.Connection = con;<br />
con.Open();<br />
cmd.ExecuteNonQuery();<br />
con.Close();<br />
}<br />
<br />
<br />
GridView1.EditIndex = -1;<br />
BindData();<br />
}<br />
<br />
<br />
<br />
|
|
|
|
|
I've just created a FormView (my first, so bare with me please), with a default mode of "Insert", bound to a SQL Server database. When I click the Insert button, the ItemInserting event fires on the FormView, but not on the SqlDataSource. I'm guessing this may be data related, but no exception is thrown. Any suggestions?
|
|
|
|
|
My bad. Even in VS 2008, I still get the extremely rude behaviour of the designer totally wiping my FormView and generating templates when I set the DataSourceID, so I work around by copying my template, setting DataSourceID, and pasting my template back. So, pasting the original template back wiped the DataSourceID.
|
|
|
|
|
Hi all
I have a user privilages form, How can I make a checkbox that checks all the checkboxes in a form ?
Thanks
Nour Abdel-Salam...
A Trainer and a Web Developer in Jedda Int'l Computer Center(JICC)
|
|
|
|
|
There are several ways, client-side JavaScript to server-side events. Clarify your requirements and you may get a more precise answer.
only two letters away from being an asset
|
|
|
|
|
Hi Mark
I prefer to get the server side events if it possible..
Regards
Nour Abdel-Salam...
A Trainer and a Web Developer in Jedda Int'l Computer Center(JICC)
|
|
|
|
|
Checkboxes has a CheckedChange event where you can verify if that checkbox is checked or not, and you check or uncheck the other checkboxes.
You can use Ajax Update panel if you want to do this without refreshing your page
Ex:
protected void allTotals_CheckedChanged(object sender, EventArgs e)
{
if (allTotals.Checked)
{
customTotals1.Checked = false;
customTotals2.Checked = false;
customTotals3.Checked = false;
customTotals4.Checked = false;
....
}
else
{
customTotals1.Checked = true;
customTotals2.Checked = true;
customTotals3.Checked = true;
customTotals4.Checked = true;
....
}
}
--------------------------------
visit: http://pmartike.deviantart.com/
|
|
|
|
|
More efficient code
protected void allTotals_CheckedChanged(object sender, EventArgs e)<br />
{<br />
customTotals1.Checked = allTotals.Checked;<br />
customTotals2.Checked = allTotals.Checked;<br />
customTotals3.Checked = allTotals.Checked;<br />
customTotals4.Checked = allTotals.Checked;<br />
}
Or even better yet, put the checkboxes in a container
protected void allTotals_CheckedChanged(object sender, EventArgs e)<br />
{<br />
foreach(CheckBox c in Panel1.Controls)<br />
c.Checked = allTotals.Checked;<br />
}
only two letters away from being an asset
|
|
|
|
|
Thanks alot sir
and how can I do it using Javascript?
Regards
Nour Abdel-Salam...
A Trainer and a Web Developer in Jedda Int'l Computer Center(JICC)
|
|
|
|
|
hello
i am begin to study object programming and the pattern and practices
in this moment i have a small project in my work
i am trying to implement pattern and practices
the application is about send email
and before this have to apply business rules
for example
rule 1 the client have to car model xxxx
rule 2 the client have to 55 years old
rule 3 etc
i have a dataset and i apply function 1 (business rule 1)
ds = applyrule1(parameter)
and to apply rule 2 i send the dataset how parameter to function 2
ds = applyrule2(ds)
ds = applyrule3(ds)
ds = applyrule4(ds)
and i have
Private Function applyrule1(ByVal ds As DataSet) As DataSet
.
.
.
.
.
.
end function
Private Function applyrule1(ByVal ds As DataSet) As DataSet
.
.
.
.
.
.
end function
the function same equal
i work with pattern and practices some one tellme a guide to Implemment pattern and practices to mi case project
thanks
|
|
|
|
|
|
|
Hi!
I have a question. How can i redirect to another page in a Button_click event. If i try with Response.Redirect("test.aspx") on test.aspx i get null values Request.Form("...") . If i try with Server.Transfer("...") i get an error:
"Sys.Webforms.PageRequestManagerParserErrorException:The message recieved from the server could not be parsed. Common causes for this error are when the response is modified by calls Response.Write(),response filters,HttpModules,or server trace is enabled. Details error parsing near ' y code:
<br />
protected void OkBTN_Click(object sender, ImageClickEventArgs e)<br />
{<br />
if (startDate <= endDate) Server.Transfer("test.aspx");<br />
else<br />
{<br />
messageLbl.Text = dateError;<br />
messageLbl.Visible = true;<br />
}<br />
}<br />
I just want to redirect to my test.aspx page and get some values with Request.Form().
Plese help me
Thank you!
Regards,
Marta Paniti.
--------------------------------
visit: http://pmartike.deviantart.com/
|
|
|
|
|
try Response.redirect(url?variables)
|
|
|
|
|
I'm sorry but i have a lot of controls on my first page... i can't transfer all those values like this
--------------------------------
visit: http://pmartike.deviantart.com/
|
|
|
|
|
Server.Transfer("test.aspx", true);
true to preserve the QueryString and Form collections; false to clear the QueryString and Form collections.
only two letters away from being an asset
|
|
|
|
|
but Server.Transfer() not working with true or without true... I got an error when i use Server.Transfer()
--------------------------------
visit: http://pmartike.deviantart.com/
|
|
|
|
|
Hello......
I want to display record in datalist from database on runtime.
just like as displayed in Featured Projects and SpotlightAgentsin www.magicbricks.com[^]
|
|
|
|
|
try searching google for the answer
there are plenty of examples of displaying data in a datalist from a database
|
|
|
|
|
hi..
I have allready searched in google...
so if u can give more details about this .. then give....
|
|
|
|
|
I think you have to create and populate a gridview , a datatable or a simple HTML table on Button_click event.
You will find a lot of examples on the internet
--------------------------------
visit: http://pmartike.deviantart.com/
|
|
|
|
|
Hallo. I'm not sure exactly what you mean from the examples you suggested, since for Featured Agens some opened into a consistent format based on MagicBricks styles and others onto their own websites. If I'm getting you correctly, here's a really simple way I'd activate a datalist (which you've already styled to look the way you want)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If IsPostBack = False Then
yourSubHere()
End If
End Sub
yourSubHere()
Using conn As New SqlConnection(as whatever)
Dim cmd As New SqlCommand("storedProcNameSelectingDatabaseContents", conn)
cmd.CommandType = Data.CommandType.StoredProcedure
conn.Open()
Using dr As SqlDataReader = cmd.ExecuteReader
datalistname.DataSource = dr
datalistname.DataBind()
datalistname.Visible = True
End Using
End Using
End Sub
Just a thought.
_________________________________________________
Have a great day!!!
-- L.J.
|
|
|
|
|
actually i want to show data in datalist in table...
i have not predefined table row in Datalist... its also create in runtime. and you can see
http://www.magicbricks.com/property/faces/jsp/indexc.jsp[^] of featured project...
In this article they show City name on runtime and then city's Content.it's not predefined how much City can have and how much content of city can add.
and i havenot predefined city. and city's content.
so how can i display this type of data in datalist at runtime..
|
|
|
|
|
My apologies - I'm not quite getting your question but it does seem beyond my current experience. . .
_________________________________________________
Have a great day!!!
-- L.J.
|
|
|
|