|
Ooooooh, how can I thank you thatraja? You have solved the real task for me. Thanks alot, I really appreciate.
|
|
|
|
|
Otekpo Emmanuel wrote: Ooooooh, how can I thank you thatraja? Please Santa...[^]
thatrajaCode converters | Education Needed
No thanks, I am all stocked up. - Luc Pattyn
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is - Henry Minute
|
|
|
|
|
Hello friends, please I need your help in this stuff. I have a datalist control on my asp.net webpage with the following buttons(Add, Remove, Cancel). I'm able to code the the button add using OnItemCommand. But, I'm unable to code the one of Remove and Cancel to call the sub procedures I wrote in vb code behind. Also, I would like a specific record to be removed from the datalist control when the remove button is click. Please help. Thanks in advance!
|
|
|
|
|
I here mention a complete code below in Data List Add,Remove and Update.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
public partial class mytesting : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetData();
}
}
private void GetData()
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=jogi;Integrated Security=True");
try
{
con.Open();
SqlCommand cmd = new SqlCommand("select * from jogi2", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
DataList1.DataSource = ds.Tables[0];
DataList1.DataBind();
}
finally
{
con.Close();
}
}
protected void DataList1_EditCommand(object source, DataListCommandEventArgs e)
{
DataList1.EditItemIndex = e.Item.ItemIndex;
GetData();
}
protected void DataList1_CancelCommand(object source, DataListCommandEventArgs e)
{
DataList1.EditItemIndex = -1;
GetData();
}
protected void DataList1_UpdateCommand(object source, DataListCommandEventArgs e)
{
String id = ((Label)e.Item.FindControl("Label3")).Text;
TextBox role = (TextBox)e.Item.FindControl("TextBox1");
TextBox password = (TextBox)e.Item.FindControl("TextBox3");
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=jogi;Integrated Security=True");
con.Open();
SqlCommand cmd = new SqlCommand("update jogi2 set role='" + role.Text + "',password='" + password.Text + "'where id ='" + id + "'", con);
int i = cmd.ExecuteNonQuery();
if (i > 0)
{
Label4.Text = "Recard Updated successfully....";
GetData();
}
}
protected void DataList1_DeleteCommand(object source, DataListCommandEventArgs e)
{
String id = ((Label)e.Item.FindControl("Label1")).Text;
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=jogi;Integrated Security=True");
con.Open();
SqlCommand cmd = new SqlCommand("delete from jogi2 where id='" + id + "'", con);
int i = cmd.ExecuteNonQuery();
if (i > 0)
{
Label4.Text = "Recard Deleted successfully....";
GetData();
}
}
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName.Equals("Insert"))
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=jogi;Integrated Security=True");
con.Open();
TextBox role = (TextBox)e.Item.FindControl("TextBox4");
TextBox password = (TextBox)e.Item.FindControl("TextBox5");
SqlCommand cmd = new SqlCommand("insert into jogi2 values('" + role.Text + "','" + password.Text + "')", con);
int i = cmd.ExecuteNonQuery();
if (i > 0)
{
Label4.Text = "Recard inserted successfully....";
GetData();
}
}
}
protected void LinkButton5_Click(object sender, EventArgs e)
{
Response.Redirect("default2.aspx");
}
}
For any problem you are faced hit to reply..
happy coding :)
jsb
|
|
|
|
|
Waooo, what a marvellous post! Banger, thank you very much. You post was easy to understand. Thanks alot...
|
|
|
|
|
i am not able to connect to remote server with filezilla that is shared hosting its giving me connection timed out error while i try to connect to remote server using their IP
|
|
|
|
|
What's your question?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hi Everybody,
I have PC with win server on it, i would like to host my site there
and access it from other computer on my network (WLAN) before i pay for hosting.
Can you help me do it?
|
|
|
|
|
|
put it in IIS,you can user IP view the web,like 192.168.1.123:801/default.aspx
|
|
|
|
|
if the host computer is server OS,you can setting DNS,if the host computer ip is 192.168.1.101,you can put it int DNS and setting ip with domain,like www.a.com but just access in WLAN
|
|
|
|
|
Hello,
How can we create own website like youtube a Dailymotion using c# Asp.Net?
Please help me.
its very urgent plz help me give me the source code plz
Thanks in Advance.
|
|
|
|
|
"Its very urgent"
"give me the source code plz"
Its not how it works around here, if you want the source code ready to go, try freelancer or vworker and pay for what you want. We are all volunteers to help you with your programming problems, not do all the work for you. Is Christmas week and I assure you, it is not urgent to us.
How do you create those kinds of sites? You start small and work your way up. It really depends on how much experience you have, since we know nothing about you, I assume you know nothing about the technologies involved and I would go so far as to say its out of your reach. Start with a small project to upload videos, then another one to display them, then another for user accounts, etc. Keep going until you've made sites with all the little pieces and then start stitching them together.
|
|
|
|
|
Inversion of control with unity container.
|
|
|
|
|
Is this a question or a statement?
Veni, vidi, abiit domum
|
|
|
|
|
i have hosted my website on shared hosting.It worked fine for few days now getting error Service Unavailable
HTTP Error 503. The service is unavailable.
pls help me with this.what to do with shared host.
|
|
|
|
|
Contact your hosting provider
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
hello
how can i place a button in the header of a command field in Grid view control?
we can do it in the template field tag simply by the header template tag but i don't know how can i do it in command field.
please help me
|
|
|
|
|
New user here. Could use your help please.
One of my ASP.net website projects (VS2012) works fine. But the others create this error in a popup: Unable to connect to the configured development web server.
Thanks in advance
|
|
|
|
|
This page has several tips on how to solve the problem: http://www.dotnetspider.com/forum/250134-Unable-connect-ASP-NET-development-Server.aspx
have checked ur ConnectionString???
|
|
|
|
|
Hello,
I am trying to execute the following query string url:
api/item?name=storm&name=prest,
but I cannot get the code to work.
I am using the split function to request same records at the same time.
public class ItemController : ApiController
{
private cdwEntities db = new cdwEntities();
public HttpResponseMessage Get([FromUri] Query query)
{
var data = db.database_ICs.AsQueryable();
if (query.name != null)
{
**data = data.Where(c => c.Name.Split("&").Contains(query.name));**
}
if (query.id!= null)
{
data = data.Where(c => c.ID== query.id);
}
if (!data.Any())
{
var message = string.Format("No data was found");
return Request.CreateErrorResponse(HttpStatusCode.NotFound, message);
}
return Request.CreateResponse(HttpStatusCode.OK, data);
}
}
Any help would be very much appreciated.
|
|
|
|
|
Your code is taking the name from the database, splitting it on the ampersand character, and looking to see if any of the parts contain the string "storm,prest" . So, for example, this would match a record where the name was "A&B&storm,prest&C" .
I suspect you want to split the name from the query, and see if it contains the name from the database.
data = data.Where(c => query.name.Split(',').Contains(c.Name));
This would return records where the name is equal to either "storm" or "prest" .
If you want to return records where the name contains any of the values passed in the querystring then it gets a little more complicated.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you so much for your response richard and thank you for clarifying the problem. Yes, that is correct, I would like the query string to return where name is either equal to 'storm' or 'prest'.
is their any example or functionality i can look at to build this method.
I really appreciate your help and time.
Many thanks.
|
|
|
|
|
The code I posted in my previous answer should do what you want, assuming the name parameter comes through as I think it will. If not, you'll need to add a breakpoint to your method and inspect the value of the query.name property to see how it's being read.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you so much for response. I amended my code according to your suggestion, but sadly I could not get the code to work. I was getting "does not recognize the method 'System.String[] Split(Char[]" error and I changed the following line of code from:
var data = db.database_BWICs.AsQueryable();
to:
public class ItemController : ApiController
{
private cdwEntities db = new cdwEntities();
public HttpResponseMessage Get([FromUri] Query query)
{
var data = db.database_ICs.AsEnumerable();
if (query.name != null)
{
data = data.Where(c => query.name.Split('&').Contains(c.Name));
}
if (query.id!= null)
{
data = data.Where(c => c.ID== query.id);
}
if (!data.Any())
{
var message = string.Format("No data was found");
return Request.CreateErrorResponse(HttpStatusCode.NotFound, message);
}
return Request.CreateResponse(HttpStatusCode.OK, data);
}
}
After, changing the above line, I was able to resolve the above error. But I still cannot request two records of name in the URL: api/item?name=storm&name=prest
It only shows the result for the first name record in the url(storm). Is there a way to execute this functionality using any any other built-in function or some kind of pseudo code.
Thank you so much for your help and time.
|
|
|
|