Click here to Skip to main content
15,891,943 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: updated grid from sql server Pin
Not Active29-Apr-10 1:52
mentorNot Active29-Apr-10 1:52 
AnswerRe: updated grid from sql server Pin
daveyerwin28-Apr-10 8:34
daveyerwin28-Apr-10 8:34 
GeneralRe: updated grid from sql server Pin
PunkIsNotDead28-Apr-10 19:55
PunkIsNotDead28-Apr-10 19:55 
GeneralRe: updated grid from sql server Pin
stassaf29-Apr-10 1:02
stassaf29-Apr-10 1:02 
GeneralRe: updated grid from sql server Pin
stassaf29-Apr-10 1:01
stassaf29-Apr-10 1:01 
GeneralRe: updated grid from sql server Pin
daveyerwin29-Apr-10 2:22
daveyerwin29-Apr-10 2:22 
GeneralRe: updated grid from sql server Pin
PunkIsNotDead29-Apr-10 16:37
PunkIsNotDead29-Apr-10 16:37 
GeneralRe: updated grid from sql server Pin
stassaf4-May-10 1:40
stassaf4-May-10 1:40 
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.
GeneralRe: updated grid from sql server [modified] Pin
PunkIsNotDead4-May-10 18:31
PunkIsNotDead4-May-10 18:31 
Questionhtml controle Pin
tek 200928-Apr-10 7:27
tek 200928-Apr-10 7:27 
AnswerRe: html controle Pin
Not Active28-Apr-10 7:46
mentorNot Active28-Apr-10 7:46 
AnswerRe: html controle Pin
Sandeep Mewara28-Apr-10 19:17
mveSandeep Mewara28-Apr-10 19:17 
GeneralRe: html controle Pin
PunkIsNotDead28-Apr-10 19:51
PunkIsNotDead28-Apr-10 19:51 
GeneralRe: html controle Pin
tek 200928-Apr-10 23:52
tek 200928-Apr-10 23:52 
GeneralRe: html controle Pin
PunkIsNotDead29-Apr-10 16:54
PunkIsNotDead29-Apr-10 16:54 
QuestionWebservice to import data Pin
Priya Prk28-Apr-10 5:05
Priya Prk28-Apr-10 5:05 
AnswerRe: Webservice to import data Pin
T M Gray28-Apr-10 6:37
T M Gray28-Apr-10 6:37 
GeneralRe: Webservice to import data Pin
Priya Prk28-Apr-10 21:05
Priya Prk28-Apr-10 21:05 
QuestionHow to Exprot Vertical Orientated Text Header to Excel Pin
Andraw11128-Apr-10 4:56
Andraw11128-Apr-10 4:56 
QuestionHow to remove the sort link after export gridview to excel Pin
Andraw11128-Apr-10 3:44
Andraw11128-Apr-10 3:44 
AnswerRe: How to remove the sort link after export gridview to excel Pin
Andraw11128-Apr-10 4:14
Andraw11128-Apr-10 4:14 
QuestionDropdownlist control problem Pin
cheguri28-Apr-10 1:56
cheguri28-Apr-10 1:56 
AnswerRe: Dropdownlist control problem Pin
daveyerwin28-Apr-10 2:04
daveyerwin28-Apr-10 2:04 
AnswerRe: Dropdownlist control problem Pin
Ankur\m/28-Apr-10 2:05
professionalAnkur\m/28-Apr-10 2:05 
AnswerRe: Dropdownlist control problem Pin
Sandesh M Patil28-Apr-10 3:16
Sandesh M Patil28-Apr-10 3:16 

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.