|
I think you should debug your code first and see what you get in DataTable.
if it is working fine then you can think of other option.
|
|
|
|
|
Thank you very much Viral Upadhyay,
My code work I, it gives me a dialog box to open or register the excel file .but it is in the server or the client?
if the file is in the server how to send the client by simple download or???
Thanks
|
|
|
|
|
Actually i am taking about is your datatable which fetch data from database has record or not?
but its look like you have done every thing right.
By the way the dialog box you see is for download or open file from server to client.
|
|
|
|
|
Thank you very much Viral Upadhyay
my english is bad i undrstand that the dialog box will be open in the pc of teachers and they will record notes and then send files to servers or directly to the database.
thank you.
|
|
|
|
|
Hi my datalist web control is bound to a database. i want to display google adsense after 3rd row. i am not sure how i can do that. could someone please help or guide me to right direction
|
|
|
|
|
I haven't done this, but the first thing I would try is using the OnDataBinding event of the datalist and insert a row if the index is 3. Make sure you don't lose the 4th row of data though.
|
|
|
|
|
could you please give me some coding tips as in how to not lose 4th row?
|
|
|
|
|
please how do i achieve this in a web program.
catch (Exception ex)
{
MessageBox.Show(ex.Message+" "+"Cannot establish the connection:" , "Connection error");
return null;
}
return cn;
}
this a class for connecting to my database.
|
|
|
|
|
Alter it to return a true/false to your webform then use a reponse.write method to generate a javascript call to the alert function with whatever message you want to show the user.
This will be the closest to what you want to do unless you want to try using Ajax Modal Popups.
|
|
|
|
|
If you have/put a scriptmanager on your page/masterpage you can do it similar to this:
private void ShowPopup(string text)
{
string alert =
"javascript:alert(\"" + text + "\");";
ScriptManager.RegisterStartupScript(this, typeof(Page), "alertscript", alert,true);
}
.....
catch (Exception ex)
{
ShowPopup(ex.Message+" "+"Cannot establish the connection");
return null;
}
return cn;
}
|
|
|
|
|
this is good stuff, but not very clear,
please could you explain the code;
in my case i have a class not the code behind class, it only does my connection,
i want to display the error message incase the connection fails.
thanks.
|
|
|
|
|
In general with a multi-tiered application the lower tiers should not know about the tiers above them. Your connection class should probably throw an ApplicationException (or better yet a custom exception derived from it) and your codebehind in the page should do a try catch and catch that particular type of exception and use the code to do the web popup.
|
|
|
|
|
You're right, this code requires to be in your page class / codebehind.
If you are trying to show a messagebox within your business logic or data layer (other class/ assembly),you should rethink that.
Try to develope your business layer as unaware of your UI as possible. Therefore, don't
show a messagebox within that BL-Class, just "raise an event" or somehow inform an interested caller about the exception (for example the page which then displays the messagebox).
I'll explain that later if necessary, as i have to go home now unfortunately:/
|
|
|
|
|
You can do it using Page.ClientScript.RegisterStartupScript .
Like :
String alertScript = "<script language='javascript'>alert('" & strMsg & "')</script>"
Page.ClientScript.RegisterStartupScript(GetType(Page), "PopupScript", alertScript)
You may also have look into this :
ASP.NET Alerts: how to display message boxes from server-side code?[^]
|
|
|
|
|
Hi,
I create a gridview which with product name and sold count in 14 regions, I put the 14 region header text in vertical orientation to fit the region text.
I put the gridview in a panel like the following, when product list is longer, the vertical scroll appear.
<asp:panel id="Panel1" runat="server" height="690px" width="100%" scrollbars="Vertical">
<gridview id="GridView1">
Everything is fine if I resize the window, the header width and gridview width are resized.
The problem is that if I want to fixed the header by using the following css:
.header1{
height:20px;
padding: 0px;
font-weight:bold;
position: absolute;
background-color:Whte;
margin-top:-3px;
margin-left:0px;
}
And add the <headerstyle cssclass="header1"> for between <gridview> tag, the header is fixed, but if I change the window size, the header size won't change, only girdview width change, this makes the fixed header is longer than girdview.
How can I solve this problem?
Thanks a lot.
|
|
|
|
|
When i save data Present in the textboxes i want to clear the textbox without writing server side code.
I think it is possible if i make
<asp:Textbox EnableViewState="false" />
But it not working.....Why?
Thanking you in advance.........
|
|
|
|
|
Try this:
<asp:Textbox Text="" EnableViewState="false" />
|
|
|
|
|
Not Working.....Thanks for reply
|
|
|
|
|
How are you saving the data? How is the data getting in the textbox in the first place? If the textbox starts off empty and the user enters the data, you click a button to save and the page reloads you could put some javascript at the bottom of the page to blank it out on client page load.
<asp:TextBox ID="txtThing" runat="server">
<script type="text/javascript">
document.getElementByID('<%=txtThing.ClientID%>').value='';
</script>
|
|
|
|
|
Hey actually i m using a user control and add this controls in it. However how i detect the user control reloads?........
|
|
|
|
|
It may be browser's 'autocomplete' feature filling it in.
You can switch it off by using:
<asp:TextBox Runat="server" ID="Textbox1" autocomplete="off" EnableViewState="false"></asp:TextBox>
|
|
|
|
|
Not Working............
|
|
|
|
|
No, disabling ViewState would not make the text go.
As far as I know, text property of a TextBox is preserved using ControlState and we do not have control over it.
Sandesh M Patil wrote: When i save data Present in the textboxes i want to clear the textbox
You must be posting the values to the server to save the data. After you save it add a line:
txtTextBoxName.Text = "";
I hope this helps!
..Go Green..
|
|
|
|
|
Hi,
I have a GridView control which is currently bound to an object which contains a DateTime property, "Survey Date". As the GridView width is limited, I want to display a checkbox instead of a DateTime to indicate that the survey has taken place. The survey is deemed to have taken place if a value has been entered for the survey date/time.
I can't bind a checkbox property using the DateTime in the GridView row can I? Somehow I'd have to check the DateTime object and if valid, set the checkbox to true and false otherwise.
Any ideas welcome!
|
|
|
|
|
Bind Your check box like this
<ASP:CkeckBOx ID="Chk1" runat="server" Checked='<%#Convert.ToDateTime(Eval("Surve_Date", "{0:dd/MM/yyyy}").ToString() == "01/01/0001" ? false: true) %>' />
|
|
|
|