|
What does your tool do if that is the only thing it would use a database for? You don't track which authors contributed to an article? You don't have the titles stored separately for convenient listing? DateTime.Now.Ticks would give you a reasonably unique ordered but non-sequential ID.
|
|
|
|
|
Yeah, I realize it sounds a bit odd. Basically, it's a kludge to make it easier to write articles that are stored in another product that is too unwieldy to use. So yes all that information does get stored but in a DB that I have no access to. Thus my app only cares about the act of creating the article and not what happens to it afterward....
|
|
|
|
|
Can you use that other system to generate the ID by creating an article stub?
|
|
|
|
|
Well if all you need is a simple way to do this you might try loading the last id from a flat text file or xml in Application_Start throw that into the application state and then in Application_End save it to the database. This way you dont have to worry about concurrency issues because the id is stored in memory and is only written back to the file when the application ends.
void Application_Start(object sender, EventArgs e)
{
int id;
int.TryParse(System.IO.File.ReadAllText(Server.MapPath("~/nextid.txt")), out id);
Application["ID"] = id;
}
void Application_End(object sender, EventArgs e)
{
System.IO.File.Delete(Server.MapPath("~/nextid.txt"));
System.IO.File.WriteAllLines(Server.MapPath("~/nextid.txt"), new string[] { Application["ID"].ToString() });
}
public int GetNextID()
{
Application["ID"] = Convert.ToInt32(Application["ID"]) + 1;
return (int)Application["ID"];
}
Ofcourse you are going to want to add stuff like checking for the file before reading it and some error handling but im sure you get the point.
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
Hi
I want to make a tips&tricks page;
I want to create something like codeproject Forums page.
What is your idea about the Component used to make this page in codeproject?
I mean the component that our questions and answers is exist and we can see our answers.(we click on the question and we can read our answer)
|
|
|
|
|
|
Hi i am trying to use data relation in my program.I have two repeaters used one nested another.
part of code is shown below:
void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
if ((item.ItemType == ListItemType.Item) ||
(item.ItemType == ListItemType.AlternatingItem))
{
Repeater2 = (Repeater)e.Item.FindControl("Repeater2");
DataRowView drv = (DataRowView)item.DataItem;
Repeater2.DataSource = drv.CreateChildView("categoryItem");
Repeater2.DataBind();
}
}
the error is :
<pre>
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: The relation is not parented to the table to which this DataView points.
Source Error:
Line 121: Repeater2 = (Repeater)e.Item.FindControl("Repeater2");
Line 122: DataRowView drv = (DataRowView)item.DataItem;
Line 123: Repeater2.DataSource = drv.CreateChildView("categoryItem");
Line 124: Repeater2.DataBind();
This categoryItem is from this code:
objDA.Fill(ds);
Repeater1.DataSource = ds;
Repeater1.DataBind();
DataColumn c1 = ds.Tables["category"].Columns["ID"];
DataColumn c2 = ds.Tables["Item"].Columns["ProposalID"];
dRel = new DataRelation("categoryItem", c1, c2);
ds.Relations.Add(dRel);
Can anyone please figure it out why that error is there ?
suchita
modified on Tuesday, July 27, 2010 9:20 AM
|
|
|
|
|
well i thought its because the repeater1.bind() is before the datarelations. So I even put that after data relations as shown :
objDA.Fill(ds);
DataColumn c1 = ds.Tables["category"].Columns["categoryID"];
DataColumn c2 = ds.Tables["Item"].Columns["catID"];
dRel = new DataRelation("categoryItem", c1, c2);
ds.Relations.Add(dRel);
Repeater1.DataSource = ds;
Repeater1.DataBind();
Now the error is :
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 1222: objDA.Fill(ds);
Line 1223:
Line 1224: DataColumn c1 = ds.Tables["category"].Columns["categoryID"];
Line 1225: DataColumn c2 = ds.Tables["Item"].Columns["catID"];
Line 1226: dRel = new DataRelation("categoryItem", c1, c2);
suchita
|
|
|
|
|
You have already asked this, eventually, before. The answer is you need to learn to read the documentation and stop throwing things together hoping it will work.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
i changed it little bit. I tried to use dataRelation before repeater get binded. that resolves the previous error but it gave different error says
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 1222: objDA.Fill(ds);
Line 1223:
Line 1224: DataColumn c1 = ds.Tables["category"].Columns["ID"];
Line 1225: DataColumn c2 = ds.Tables["item"].Columns["catID"];
Line 1226: dRel = new DataRelation("categoryItem", c1, c2);
my code is:
void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
if ((item.ItemType == ListItemType.Item) ||
(item.ItemType == ListItemType.AlternatingItem))
{
Repeater2 = (Repeater)e.Item.FindControl("Repeater2");
DataRowView drv = (DataRowView)item.DataItem;
Repeater2.DataSource = drv.CreateChildView("categoryItem");
Repeater2.DataBind();
}
}
the changed code is in this block:
objDA.Fill(ds);
DataColumn c1 = ds.Tables["category"].Columns["ID"];
DataColumn c2 = ds.Tables["Item"].Columns["catID"];
dRel = new DataRelation("categoryItem", c1, c2);
ds.Relations.Add(dRel);
Repeater1.DataSource = ds;
Repeater1.DataBind();
the "ID" of table "category" is the foreign key in "item" table and that foreignKey name in the "item" table is "catID". But the error is something wrong with those IDs.
suchita
|
|
|
|
|
how to find whether div style is already visible or hidden using jquery in aspx page.
i have now like
<pre>if( $('#obj').css('display') == "none" )
{
alert('hi');
}
else
{
alert('hi%');
}</pre>
|
|
|
|
|
if( $('#obj').is(":visible") == true )
{
alert('div is visible');
}
else
{
alert('div is hidden');
}
|
|
|
|
|
Thanks for your reply ,
my hidden is open but it still shows invisible.
pls advice me
function expandcollapse(obj,row)
{
debugger;
alert(obj+'expandcollapse');
var div = $('#obj');
var img = 'img' +obj;
alert($('div').css('display'))
}
|
|
|
|
|
|
Hi all
I need to get backup of my database(sql 2005 & above) in script format not in.bak format.How can I do this?
I need all like tables,& table records,Store procedure etc in script format this is important.
Any help would be appreciated......
Amit
|
|
|
|
|
Hi friends
I have defalut.aspx page in My web Application. I want to load dynamic content into this page.
for example if i have url "http://www.cricinfo.com" which contains html content right. so i want to load this content into my default.aspx page.
Please help me how to do it?
|
|
|
|
|
I think you can use iframe for achieving this.
|
|
|
|
|
You can use Streamreader to read the content and assign it to the control(Ex. Label) on your default.aspx page.
We successfully implent it. However we have the permission to access the data from another website.
|
|
|
|
|
hi guys very good morning to u all,
i have created vs2005 project and upgraded it into vs2008,
while convert its asked to take backup and i too did the same,and the project has been upgraded...,
now i like to get my vs2005 project back...,
its possible to get it same ?
Thanks & Regards,
Member 3879881,
please don't forget to vote on the post
|
|
|
|
|
If you selected backup option, then check for back up folder in the solution folder.
|
|
|
|
|
Hi,
I have question regarding using nested repeater. Can we use nested repeater in ascx file in asp.net ? Well I tried to use but the name of the child repeater is not recognizing. Can anybody has any idea on that ?
thanks
suchita
|
|
|
|
|
SayamiSuchi wrote: Can we use nested repeater in ascx file in asp.net ?
It's an ASP.NET control, why couldn't you use it?
Why don't you show what you have done so we can help point out what may be wrong.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Sure. Thanks for the reply. Well these are the codes.
<asp:Repeater runat="server" id="Repeater1">
<HeaderTemplate>items<br /><br /></HeaderTemplate>
<ItemTemplate>
<b><%# DataBinder.Eval(Container.DataItem, "catagoryname") %></t>
<br><%# DataBinder.Eval(Container.DataItem, "catagorydescription") %>
<asp:Repeater ID="Repeater3" runat="server">
<ItemTemplate>
<br>Items: <%# DataBinder.Eval(Container.DataItem,"ItemName")%></t></t></t><%# DataBinder.Eval(Container.DataItem, "Amount") %>
<br><%# DataBinder.Eval(Container.DataItem, "ItemDescription") %></br>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
<separatortemplate>
<br />
<br />
<br />
</separatortemplate>
</asp:Repeater>
I have these in my ascx page.
suchita
|
|
|
|
|
You won't be able to access the Repeater3 control from the ascx directly as a new one is created for each databound item.
If you handle the OnItemDataBound event on Repeater1 you'll be able to access the Repeater3 control using:
e.Item.FindControl("Repeater3")
|
|
|
|
|
Martin Jarvis wrote: You won't be able to access the Repeater3 control from the ascx directly
Why not? See below.
I know the language. I've read a book. - _Madmatt
|
|
|
|