|
Thanks PunkIsNotDead,
your replt is very helpfull and it's the base for what i'm doing.
insted of "your content here" i'm using a datagrid that updates.
but the tricky part is that i want to be able to update only the certain cell data that was changed and not the whole grid.
also there could be n grids on my page and i can't know on advance how mant grid should be, also during running more grids can be added.
currently every "Tmr_Update_Tick" i'm doing a merge between the current datatable and the new one that i'm getting from the DB.
how can i do cell update, maybe even highlight it when there's a change?
also use n grids when n is known before runung?
my code right now shows one grid with the current data and one grid with only the changes:
.aspx
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Timer ID="Tmr_Update" runat="server" ontick="Tmr_Update_Tick"/>
<asp:UpdatePanel ID="UpdPnl_UpdateEvery_5Sec" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="Server"></asp:GridView>
<br /><br /><br />
<asp:GridView ID="GridView2" runat="Server"></asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Tmr_Update" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
.cs
protected string connStr = "xxxx";
protected DataTable dTable = new DataTable();
protected DataTable dTable1 = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
//On Load
Tmr_Update.Interval = 100000;//seconds
if (!IsPostBack)
{
GetDT(ref dTable);
BindGridView(ref dTable);
}
}
private void GetDT(ref DataTable myDT)
{
SqlConnection conn = new SqlConnection(connStr);
conn.Open();
SqlCommand objComm = new SqlCommand();
objComm.Connection = conn;
objComm.CommandType = CommandType.StoredProcedure;
objComm.CommandText = "someSP";
SqlDataAdapter dAd = new SqlDataAdapter(objComm);
dAd.Fill(myDT);
conn.Close();
}
private void BindGridView(ref DataTable myDT)
{
GridView1.DataSource = myDT;
GridView1.DataBind();
}
protected void Tmr_Update_Tick(object sender, EventArgs e)
{
//
GetDT(ref dTable1);
//dTable.Merge(dTable1);
DataTable d3 = new DataTable();// = dTable1.GetChanges();
d3.Merge(dTable);
d3.AcceptChanges();
d3.Merge(dTable1);
GridView1.DataSource = dTable1;
GridView1.DataBind();
GridView2.DataSource = d3.GetChanges();
GridView2.DataBind();
dTable = dTable1;
}
Thanks,
Assaf.
|
|
|
|
|
Hi! you could use jQuery highlight effect Here[^]. Is the first thing I think you can use in to Highlight a cell.
And try using a updatepanel in a
<asp:templatefield headertext="Prueba">
<itemtemplate><asp:updatepanel runat="server" id="UpdPnl_Test" updatemode="Conditional">
< ContentTemplate>
< div class="DivTest">< %#Eval("DataToUpdate")%>< /div>
< / ContentTemplate>
< Triggers>
< asp:AsyncPostBackTrigger ControlID="Tmr_Update" EventName="Tick" / >
< / Triggers>
< / asp:UpdatePanel>
< / ItemTemplate>
< / asp:TemplateField>
and on the timer.tick event you must compare the last data and the new. and performing the jQuery event in which divs satisfy the condition of "diferent than last time" or something like that.
That would be hard men...
would be like < div... ...showHL='< %#Eval("UpdateThis")%>'> ...
and in the DataTable add a column with 'UpdateThis' to change (from false to true for example) in case that the last data changed too. And in script side you must select all divs that have changed every post back (or timer.tick)
$(document).ready(function(){
$('div[showHL="true"]')effect(
$("#effect").effect(selectedEffect,options,500,callback););
//callback function to bring a hidden div back
function callback(){
setTimeout(function(){ $('div[showHL="true"]').removeAttr('style').hide().fadeIn();
}, 1000);
});
note: jQuery function is not tested and i'm not sure of if it's sintax is ok too.
modified on Wednesday, May 5, 2010 12:38 AM
|
|
|
|
|
hello everyone,
I'm working on n-tier application and I want to use html controls, for example, instead of dropdownlist I'll use the select and instead of gridview I'll use a html table,
the problem that I could not fill them using sql query, and all the result of research on google there are php, if someone can help me in this level, thank you
|
|
|
|
|
Well, all ASP.NET controls render as html controls so I don't see what the issue is.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
membre123 wrote: instead of dropdownlist I'll use the select
This should be fine and there must not be an issue filling either one. Both expose similar properties to fill the values.
membre123 wrote: instead of gridview I'll use a html table,
This is tough! Though Gridview is rendered as table but the way values are defined for both, pagination, sorting, etc will be missing in Table... It cab be done with effort!...
What is the reason you are trying to convert them so? Ultimately ASP.NET controls are rendered as HTML only!
Further, what exact issue you are facing while filling them using SQL query - i dont find any reason you shouldn't be able to!
|
|
|
|
|
Hi! use in select and table like this...
<select id="yourAspSelectID" runat="server"></select>
<table id="yourAspTableID" runat="server"><tr><td>Content</td></tr></table>
And then you could reference it's id in code behind!
good luck
|
|
|
|
|
ok, thank you, so I'll link id for each control so my c code, for example if I want to fill a select controle by a "select client from id_clt" I'll do it:
in DAL:public SqlDataReader selection (string agrecvt)
{
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "selectioncvt";
cmd.CommandType = CommandType.StoredProcedure;
using (SqlDataReader dr=cmd.ExecuteReader())
{
while (dr.Read())
{
agrecvt = Convert.ToString(dr["@agremcvt"]);
}
return dr ;
}
}
in BLL: public SqlDataReader selection(string agrecvt)
{
try
{
return cvtdal.selection (agrecvt );
}
catch
{
throw;
}
finally
{
cvtdal = null;
}
}
and in code interface:
protected void Page_Load(object sender, EventArgs e)
{
busniss_object.Classe_cvt cvt = new busniss_object.Classe_cvt();
Select4.DataSource = cvt.selection();
}
but it does'nt work if you can correct my code, thank you
|
|
|
|
|
I fill it with a DataTable like this...
DataTable Dt = new DataTable("Dt_Source");
Dt.Columns.Add("Id", System.Type.GetType("System.Int32"));
Dt.Columns.Add("Name", System.Type.GetType("System.String"));
Dt.Rows.Add(1, "Text1");
Dt.Rows.Add(2, "Text2");
Dt.Rows.Add(3, "Text3");
Dt.Rows.Add(4, "Text4");
Select1.DataSource = Dt;
Select1.DataTextField = "Name";
Select1.DataValueField = "Id";
Select1.DataBind();
good luck!
|
|
|
|
|
Dear all,
Im new in this and hope to get some advice.
I want to build a webservice that has to get some data as parameter from the client application. the data from the client side are records from there database.
my websercie has to send then these data to a soap server through 'HttpWebRequest'.
Can i get the data as Datatable? and then send as stream to the soap server?
Or maybe there is a better easier ways? your suggestion please
Thanks in advance.
|
|
|
|
|
A datatable is going to add a lot of overhead. I would suggest creating a class that represents the stuff you have in a row. That would then be a parameter of your web service. Those are known as "complex types" in the web services world. How you send it on after that depends on what is on the receiving end. Just saying it is SOAP doesn't give enough detail to say what kind of format it would accept. Are you doing anything with the data on the web server before you send it on? It seems like you are adding a middle man for no reason.
|
|
|
|
|
Hi T M Gray,
Thank you for reply!
By creating a class that represents the stuff in a row, the client app has to send then each record separately, so they have to call the webservice once for each record. Don't we have this way more overhead then sending the entire datatable at once?
And yes the webservice is acting as middle man between internet and the soap server for security reasons. the webservice has to send the data as string to that soap server.
|
|
|
|
|
Hi, all,
I have a gridview table with some columns vertical orientated, but after export to excel, all the column headers are horizontal, how can I keep the same format as gridview?
Also set the header row height after exported to excel?
Thanks!
|
|
|
|
|
Hi, all,
I have a gridview with sorting header, after I export it to excel, the links are still there, how can I remove the sort link?
I search the internet, somebody suggest using the following codes in Export_Click method:
GridView1.AllowSorting = false;
GridView1.DataBind();
But after I use this, the generated excel file have no data at all, only some html codes line .... .
Can anybody help me? Thanks!
|
|
|
|
|
|
Dear Friends,
I have three dropdownlist controls. When the page loads, first dropdownlist is filled and the remaining two are empty. When I select some value in First dropdownlist then corresponding values to be populated in Second dropdownlist and same When I select some value in Second dropdownlist then corresponding values to be populated in Third dropdownlist. The problem is, Whatever I select in the First dropdownlist automatically the first item only getting selected. Even If I selected the 5th Item, then also the First Item only getting selected. Please solve my problem.
Thanks & Regards,
Dileep.
|
|
|
|
|
Here is a simple example concerning updating derop
down list based on selction in another drop down ...
<%@ Page Language="C#" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
DropDownList1.Items.Clear();
String[] ds = {"hi RED","sup RED"};
String[] ds1 = { "hi BLUE", "sup BLUE" };
if (DropDownList2.SelectedValue == "RED")
{
DropDownList1.DataSource = ds;
DropDownList1.DataBind();
}
if (DropDownList2.SelectedValue == "BLUE")
{
DropDownList1.DataSource = ds1;
DropDownList1.DataBind();
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
<style type="text/css">
#UpdatePanel1 { width:300px; height:100px; } </style>
</head>
<body>
<form id="form1" runat="server">
<div style="padding-top: 10px">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<fieldset>
<legend>UpdatePanel</legend>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server">
<asp:ListItem>RED</asp:ListItem>
<asp:ListItem>BLUE</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
<br />
</div>
</div>
</form>
</body>
</html>
|
|
|
|
|
Your description doesn't tell me much about the cause of your problem. Could you post some code, so that we may be able to help you.
..Go Green..
|
|
|
|
|
Are you binding the dropdown in page_load event. If so is it within if(!Ispostback) ?
I think thats the problem you did not bind the dropdown within if(!Ispostback)
I think this may help u.............
|
|
|
|
|
Your problem could it be like sandympatil said! or maybe you're setting the same dropDownList1.DataValueField in the data source...
for example I have as source:
-column1----column2
---------------------
-red------------value1
-blue-----------value1
-orange-------value1
-black----------value1
and dropdownlist is
dropDownList1.DataTextField = "column1";
dropDownList1.DataValueField = "column2";
look out that. If that's so, the post back always select the first option with 'value1'... Ahh! I recommend you to use ajax CascaddingDropDownList Here!![^]
|
|
|
|
|
Hi guys, am trying to empty my datagrid before i bind new records(items)
I tried the following but they won't work:
myDataGrid.DataSource = null;
myDataGrid.DataBind();
or
myDataGrid.Dispose();
|
|
|
|
|
Even if you empty your grid it'll populate with the new records.then Why you want to empty datagrid before binding with new records?
|
|
|
|
|
From the example program in my reply
to cheguri ...
DropDownList1.Items.Clear();
|
|
|
|
|
Try this :
<br />
DataTable dt = new DataTable;<br />
myDataGrid.DataSource = dt;<br />
|
|
|
|
|
I have one web page with 4 RadioButtonList controls and some panels.
I want to view specific panel content depending on radio buttons.
For example,
RadioButtonList1 (RBL1) contains 3 radio buttons.
each radio button will show one another RadioButtonList Control.
And each radiobutton of other RadioButtonLists will show correcsponding panels.
I have done this one in normal code behind concept. When I add Update Panel control, it doesn't work in Google Chrome.
Please give me a help.
|
|
|
|
|
Hi Experts,
I have designed and coded all my report pages.As my data is more then 500 charactres in one of my fied, the entry directly goes to second page and the first page remains blank as i have a page header covering 1/4th space in my first page....
Thus i wanted to have data on first page also and continue the remaining data on second page....Is there any property that i m forgetting to assign ?
Please Help.
Sharing Of Knowledge Provides Solution....
|
|
|
|