|
Hey Guys - would like to ask you guys for advice -
[History]
I have a table which I will grab from my sql server and place into a gridview(limited view/sample of data specific data to give users enough info to select a row). Now each row is selectable and once selected I would like to get the rest of the data which corresponds from the row selected - so users are able to view and be able to edit the related data. (This first part is completed I can select the data and get the pri key related to the selected row and pass it to page)
[Question]
What would be the best way for me to give the users the ability to view the data, edit the data, update, and delete it(I only need one set of buttons at the top of the page)? The data be retrieved is big. I don't need the ability to page threw the data as in dataview - Would like to get some feed back on ideas andor with some examples.
I appreciate any advice....
Thanks Nick
|
|
|
|
|
Add a detailsview grid to the gridview page. There are plenty of examples on MSDN
|
|
|
|
|
My title may not be very clear, but what it means is that normally, when we have a data set, the columns (along x-axis) refer to the properties of a specific record in the data set, whereas all the records of this data set are listed vertically (y-axis). The asp:DataGrid also works this way, in that you can have a data set with a variety of columns (BoundColumn, TemplateColumn, ButtonColumn, etc.) which all denote properties of your data. An advantage of this is that for each record, you can specify for example, that a certain column is a TemplateColumn with a DropDownList bound to another data set, allowing you to pick and choose from this data.
Given this background, the problem I'm having is that I want the records to be like new columns, and the fields to be a fixed set of rows (essentially inverting the x and y-axis of the standard data grid). If I use a pivot table (just a DataTable with a pivot function that allows you to switch the x/y-axes) as a data source, I can get the data displayed by the data grid just fine. What I can't do, however, is make it so that the data grid has "TemplateRow" (this construct does not exist) and bind certain rows to data via a DropDownList, assuming I want to make this data editable.
Does anyone know of a quick way to do this or do I essentially have to take apart the standard asp:DataGrid / spend a lot of time extending its functionality so that I can do the following:
<asp:DataGrid>
<asp:TemplateRow>
<asp:ItemStyle>
<asp:DropDownList DataSource="someDataSource"></asp:DropDownList>
</asp:ItemStyle>
</asp:TemplateRow>
</asp:DataGrid>
|
|
|
|
|
You need to use a repeater to have that level of control over the output. Even then, you want to use a pivot table for your data
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Thanks, I will have a look at this control.
|
|
|
|
|
Dear All,
I am creating an web project not an web site.
It includes a module for News, the user can add images for the news.
I am able to add it in the folder in my applicaiton.
But while viewing, i am getting the path as Server.Mappath("<imagename>".
While debugging it is getting the path correctly, but it is not displaying the image.
Can any one tell me a solution to get rid of this?
Thanks a lot in advance.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
Can you please put the code block for that sections?
|
|
|
|
|
Hi,
I have a problem with my divs. I have created an Accordian Ajax Control from the Ajax Control Toolkit. This control when one of the tabs is open it overlays on the footer div. I need that the footer changes position according to the size of the accordian component in this div. Im doing the positioning through CSS. Can some one help me on this please? Thanks for your time.
Regards
|
|
|
|
|
In Which browser ?
I also have some problem with the layout in IE6 and IE7. In my case I just assigned some value to the "Height" Property and It works fine. Before that It was overlapping.
These are some common problems with IE6 and Accordian.
The AutoSize "Limit" mode works exactly the same as the "Fill" mode for Internet Explorer 6 and 7 because they do not support the max-height CSS property.
If you place the Accordion inside a <table> tag and have FadeTransitions set to true in Internet Explorer 6, it will affect the spacing between Accordion Panes.
|
|
|
|
|
Yes with IE7. The thing is that the div that the accordian is in does not change size when the accordian changes size so i can't move the footer down.
ill probably do like as you say.
Thanks for your help.
|
|
|
|
|
before footer div write an empty div with style property clear:both it will solve your problem....
umerumerumer
|
|
|
|
|
I implemented the div but it didnot work. Thanks for your help anyway.
|
|
|
|
|
hi everyone...
iam working on gridview with checkboxes... iam executing my code without any Errors. i can check/uncheck the checkboxes but not able to delete the row/rows in Grid on Delete_Click().
According to me there is a problem with DeleteRow Function..
So can anyone helpme out in this regard...
thanx in advance..
Here is my aspx.cs Code:
protected void btnDelete_Click(object sender, EventArgs e)
{
// This variable contains the selected rows in the format 1,2,3
string SelectedRows = GetSelected();
// User defined function that calls the stored proc to delete the selected items
DeleteRows(SelectedRows);
}
public static void DeleteRows(string PTittle)
{
SqlConnection MyConnection = new SqlConnection("server=(local);database=BlogDatabase;UID=sa;PWD=meritinfo;");
SqlCommand MyCommand = new SqlCommand("Delete from Posts where PTittle=@PTittle ", MyConnection);
MyCommand.Parameters.Add(new SqlParameter("@PTittle", PTittle));
MyCommand.CommandType = CommandType.Text;
MyCommand.Connection.Open();
SqlDataReader dr = null;
dr = MyCommand.ExecuteReader();
//DataTable Posts = new DataTable();
//DataTable dt = new DataTable();
//dt.Load(dr);
//if (dt != null)
//{
// Posts = dt;
//}
}
|
|
|
|
|
Whether it is getting deleted fro database?
Cheers!!
Brij
|
|
|
|
|
No brij,
its not delete from database...
thanx.....
|
|
|
|
|
use ExecuteNonQuery() for deleting from Database.If it gets deleted then bind again with the Grid
Cheers!!
Brij
|
|
|
|
|
Hi prem,
Use MyCommand.ExecuteNonQuery();
and after deleting Bind the grid again .
Try Karke Dekho , Koi Problem ho toh reply karna
|
|
|
|
|
hi,nishant
MyCommand.ExecuteNonQuery()
is also not giving output...
any other sol plz....
once go through the code:
protected void btnDelete_Click(object sender, EventArgs e)
{
// This variable contains the selected rows in the format 1,2,3
string SelectedRows = GetSelected();
// User defined function that calls the stored proc to delete the selected items
DeleteRows(SelectedRows);
}
public static void DeleteRows(string PTittle)
{
SqlConnection MyConnection = new SqlConnection("server=(local);database=BlogDatabase;UID=sa;PWD=meritinfo;");
SqlCommand MyCommand = new SqlCommand("Delete from Posts where PTittle=@PTittle ", MyConnection);
MyCommand.Parameters.Add(new SqlParameter("@PTittle", PTittle));
MyCommand.CommandType = CommandType.Text;
MyCommand.Connection.Open();
//SqlDataReader dr = null;
//dr = MyCommand.ExecuteReader();
//dr.Close();
MyCommand.ExecuteNonQuery();
//DataTable Posts = new DataTable();
//DataTable dt = new DataTable();
//dt.Load(dr);
//if (dt != null)
//{
// Posts = dt;
//}
}
|
|
|
|
|
Aise Likho
SqlConnection MyConnection = new SqlConnection("server=(local);database=BlogDatabase;UID=sa;PWD=meritinfo;");
SqlCommand MyCommand = new SqlCommand("Delete from Posts where PTittle=@PTittle ", MyConnection);
MyCommand.Parameters.Add(new SqlParameter("@PTittle", PTittle));
MyCommand.CommandType = CommandType.Text;
MyCommand.Connection=MyConnection;
MyConnection.open();
MyCommand.ExecuteNonQuery();
Aise Chala kar ke Dekho
|
|
|
|
|
sorry yaar ,
still not...
i think in DeleteRow(______), the parameter should empty
couz connection and commands are all ok..
what do u think..
thank for ur help....
|
|
|
|
|
Are u sending string of Selected Rows like
Ptittle="1,2,3,5" Like this ???
If like that then ur Delete Query dosen't work
becuase it will be like that
"Delete from Posts where Ptittle=1,2,3,5"
This won't work
Write like that
"Delete from Posts where Ptittle In ("+@Ptittle+")"
mein Salah doonga ki
Debug the Code and see What is the Command text
|
|
|
|
|
see yaar.
at MyCommand.ExecuteNonQuery ....SqlException raised--->Incorrect Syntax near ','
command text=
Delete from Posts where PTittle In (,)
|
|
|
|
|
good evening ,
i am trying new code now....here i can bring all checkbox selected fields PTittle value in a string gvID's...and passing to delete command...
but at ExecuteNonQuery() the Error raised that Incorrect Syntax near gvID's value...(for eg:Political Influence on Students is the value in
the string contains PTittle Values Collection...saying Syntax Error near Influence....
Here is the Code: .aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" DataKeyNames="PTittle">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<input type="checkbox" id="CheckAll" onclick="return check_uncheck (this );" runat="server" />
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="tittle" Visible="false"
Text='<%# DataBinder.Eval (Container.DataItem, "PTittle") %>' runat="server" />
<input type="checkbox" id="deleteRec" onclick="return check_uncheck (this );" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Author" HeaderText="Author" SortExpression="Author" />
<asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
<asp:BoundField DataField="PTittle" HeaderText="PTittle" SortExpression="PTittle" />
<asp:BoundField DataField="Category" HeaderText="Category" SortExpression="Category" />
<asp:BoundField DataField="Tags" HeaderText="Tags" SortExpression="Tags" />
<asp:BoundField DataField="PStatus" HeaderText="PStatus" SortExpression="PStatus" />
<asp:BoundField DataField="TotalComments" HeaderText="TotalComments" SortExpression="TotalComments" />
</Columns>
</asp:GridView>
<asp:Button ID="Button1" runat="server" OnClientClick="return confirmMsg(this.form)" Text="Button" OnClick="Button1_Click" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BlogDatabaseConnectionString %>"
SelectCommand="SELECT [Author], [Date], [PTittle], [Category], [Tags], [PStatus], [TotalComments] FROM [Posts]">
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
<script type="text/javascript" language="javascript" >
function check_uncheck(Val)
{
var ValChecked = Val.checked;
var ValId = Val.id;
var frm = document.forms[0];
for (i = 0; i < frm.length; i++)
{
if (this != null)
{
if (ValId.indexOf('CheckAll') != - 1)
{
if (ValChecked)
{
frm.elements[i].checked = true;
}
else
{
frm.elements[i].checked = false;
}
}
else if (ValId.indexOf('deleteRec') != - 1)
{
if (frm.elements[i].checked == false)
{
frm.elements[1].checked = false;
}
}
}
}
}
function confirmMsg(frm)
{
for (i = 0; i < frm.length; i++)
{
if (frm.elements[i].name.indexOf("deleteRec") != - 1)
{
if (frm.elements[i].checked)
{
return confirm("Are you sure you want to delete your selection(s)?")
}
}
}
}
</script>
Here is the Code: .aspx.cs
using System;
using System.Data;
using System.Configuration;
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;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string gvIDs = "";
bool chkBox = false;
//'Navigate through each row in the GridView for checkbox items
foreach (GridViewRow gv in GridView1.Rows)
{
HtmlInputCheckBox deleteChkBxItem = (HtmlInputCheckBox)gv.FindControl("deleteRec");
if (deleteChkBxItem.Checked)
{
chkBox = true;
// Concatenate GridView items with comma for SQL Delete
gvIDs += ((Label)gv.FindControl("tittle")).Text.ToString() + ",";
}
}
SqlConnection cn = new SqlConnection(SqlDataSource1.ConnectionString);
if (chkBox)
{
// Execute SQL Query only if checkboxes are checked to avoid any error with initial null string
try
{
//string deleteSQL = "DELETE from Posts WHERE PTittle IN (" + gvIDs.Substring(0, gvIDs.LastIndexOf(",")) + ")";
SqlCommand cmd = new SqlCommand("DELETE from Posts WHERE PTittle IN (" + gvIDs.Substring(0, gvIDs.LastIndexOf(",")) + ")", cn);
cn.Open();
cmd.ExecuteNonQuery();//Error:After ExecuteNonQuery
GridView1.DataBind();
}
catch (SqlException err)
{
Response.Write(err.Message.ToString());
}
finally
{
cn.Close();
}
}
}
}
|
|
|
|
|
Is there any remort logger file for remote desktop connection? I have to handle add/update/deletion of the log details.
Is it possible?Plz advice and update me.
Muthu
|
|
|
|
|
Pls be so kind to use google with the query: "log4net"...
|
|
|
|