|
Check this[^] boy, and so much more clikety[^], IMHO you should take Mike's advice, learn it and do it as I believe that googling for your questions takes less time than posting and waiting for help.
|
|
|
|
|
Sir,
What is view state and What's the viewstate of textbox.
Please explain.
thanks.
|
|
|
|
|
|
Sir,
What 's the difference between one , two and three tier architecture.
Thanks
|
|
|
|
|
This is a great question for Google.
I plugged in your question and got this link as an answer:
http://www.developerfusion.co.uk/show/3058/2/[^]
Here's how to do it:
1) - use your web browser to point to http://www.google.com[^]
2) - in the text box on the Google page, enter your question or something you'd like to search for
3) - click the button labeled "Google Search".
After that, you'll get a new page with a list of links that Google thinks matches your question or search terms. Click on some of the links to see the results. There are also paging links at the bottom, so you can get more results if you want.
|
|
|
|
|
Hi Guys
I am facing problem while connecting asp.net 2.0 program to sqlserver 2000 database. database is on remote machine. error is..
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
It is working perfectly in local system
Regards
Shanti Bhushan
|
|
|
|
|
|
Dear Stephan Pilz ,
My name is senthil , from INDIA.
I download your project of multilingual web site from "Codeproject" portal, your example is very nice.
Now My question is "I want to type the data in particular language itself " and i want to save the same in to sql-server 2000"
(I want to discuss more in this i you like)
I wating for your reply.
Thanks
Wtih regards
Senthil
|
|
|
|
|
hello, everyone:
I am creating a DataGrid form a DataSet with autogeneratecolumns:
dg.DataSource = ds;
dg.DataBind();
But I want to change the style of the columns. Particularly speaking, i want to have all the columns have fixed width/height so that the datagrid may look better. It is because some of the content may have many words. I have tried many methods,however, the datagrid never changed.
Any ideas?
ThanX in advance!
|
|
|
|
|
Yea, this can be tricky when auto-generating the columns, because you don't have direct access to the columns. Here's a hack you can try - it involves trapping the PreRender event for the datagrid (this assumes the data is bound prior to PreRender) and manually inspecting the grid's child control Table. Below is an example of what I mean.
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<script runat="server">
void Page_Load(object o, EventArgs e)
{
if (!IsPostBack)
{
myList.DataSource = CreateDataSource();
myList.DataBind();
myList2.DataSource = CreateDataSource();
myList2.DataBind();
}
}
private DataTable CreateDataSource()
{
DataTable t = new DataTable();
DataColumn c = new DataColumn();
c.DataType = System.Type.GetType("System.Int32");
c.ColumnName = "ID";
c.Unique = true;
t.Columns.Add(c);
c = new DataColumn();
c.DataType = System.Type.GetType("System.String");
c.ColumnName = "Name";
t.Columns.Add(c);
c = new DataColumn();
c.DataType = System.Type.GetType("System.String");
c.ColumnName = "City";
t.Columns.Add(c);
DataColumn[] primaryKey = new DataColumn[1];
primaryKey[0] = t.Columns["ID"];
t.PrimaryKey = primaryKey;
DataRow r = t.NewRow();
r["id"] = 1001; r["Name"] = "Jack Bauer"; r["City"] = "Los Angeles";
t.Rows.Add(r);
r = t.NewRow();
r["id"] = 1002; r["Name"] = "David Palmer"; r["City"] = "Washington D.C.";
t.Rows.Add(r);
r = t.NewRow();
r["id"] = 1003; r["Name"] = "Nina Meyers";
r["City"] = "Los Angeles"; t.Rows.Add(r);
r = t.NewRow();
r["id"] = 1004; r["Name"] = "Bill Buchanan";
r["City"] = "Los Angeles"; t.Rows.Add(r);
return t;
}
private void DG_PreRender(object o, EventArgs e)
{
DataGrid dg = (o as DataGrid);
if (dg != null)
{
Table t = (dg.Controls[0] as Table);
if (t != null)
{
if (t.Rows.Count > 0)
{
foreach(TableCell tc in t.Rows[0].Cells)
{
tc.Width=new Unit("200px");
}
}
}
}
}
</script>
<html>
<head>
<title>Fixing Columns in a AutoGenerateColumns DataGrid</title>
<style> body {font-family: 'Tahoma'; font-size: 10pt;}
td {font-size: 10pt;}
</style>
</head>
<body>
<form runat="server">
<h3>Fixing Columns in a AutoGenerateColumns DataGrid</h3>
<p>DataGrid without "fixing"</p>
<asp:DataGrid id="myList" runat="server"
AutoGenerateColumns="true"
/>
<br /><br />
<p>DataGrid with "fixing"</p>
<asp:DataGrid id="myList2" runat="server"
AutoGenerateColumns="true"
O n P r e R e n d e r="DG_PreRender"
/>
<%----%>
</form>
</body>
</html>
|
|
|
|
|
Hello ,
I tried using your code but the page displayed following error on line 66..
Server Error in '/CodeProject' Application.
Specified argument was out of the range of valid values. Parameter name: index
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.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: index
Source Error:
Line 64: if (dg != null)
Line 65: {
Line 66: Table t = (dg.Controls[0] as Table);
Line 67: if (t != null)
Line 68: {
..pls can u figure out what the problem is
Thanks,
Mini
|
|
|
|
|
Hi Mini. The code worked as is for me... did you change the datasource or when the data is bound?
The one thing about the technique I demonstrated is that the data must be bound to the grid before the PreRender (or other event of choice) is triggered. If the data isn't bound, then there isn't a child Table control to inspect, and I'm guessing that's why you're getting an error referencing dg.Controls[0] .
Another way to go about this, that is probably better anyway, is to use the ItemDataBound event of the DataGrid. Take a look at the event documentation for it on MSDN and you'll see an example of how it is used. It's very similar to the approach I showed here, except that you'll access a table row and its cells through the event args that are passed to the ItemDataBound event handler, rather than accessing the child Table control directly.
If there's interest, I might be able to work up an article on this fairly quickly.
|
|
|
|
|
Thank u, Mike and miniThomas, for the attention.
I have tried both of the approach, however, the datagrid is still not changed. I am wondering if it is beacause the width of the datagrid could not be longer than certain value, for some of the columns are really quite long. looking forward to ur further answer.
Regards,
Steven
|
|
|
|
|
Hi Steven. I do think you'll want to trap ItemDataBound in your datagrid. You can Google "ItemDataBound" for examples.
I've submitted an article about this topic that will hopefully get posted soon that also shows an example.
|
|
|
|
|
Thank u for ur reply, looking forward to ur new article.
|
|
|
|
|
Hello Mike,
Like Steven looking forward to ur article
Thanks,
Mini
|
|
|
|
|
|
|
Hi All
I have a datagrid & I want it to be sorted when the user clicks on the column header..How can I do that??
Thanks a lot in advance
Happy
|
|
|
|
|
it's very simple
use this function in your class file or at code behind
public void BindGrid(DataTable dt, DataGrid dg, string sortexpression, string order)
{
try
{
if (dt.Rows.Count > 0)
{
DataView dv;
dv = dt.DefaultView;
if (sortexpression != "")
{
if (order == "desc")
dv.Sort = sortexpression + " DESC";
else
dv.Sort = sortexpression;
}
dg.DataSource = dv;
dg.DataBind();
}
}
catch (Exception ex)
{
clsLog.WriteLog(ex.Message);
throw ex;
}
}
where, argument1=datatable object where you hv stored the data which you would like to display
2.argument2=your datagrid id
3.argument3=variable(here u cn take sortexpression which you will declare at the beginning like this private string sortexpression = "";)
4.argument4= Convert.ToString(ViewState["order"])
now on click of column_header event write the code
LinkButton lnkbtn;
lnkbtn = (LinkButton)sender;
if (Convert.ToString(ViewState["order"]) == "Asc")
{
ViewState["order"] = "desc";
}
else
{
ViewState["order"] = "Asc";
}
if (lnkbtn.Text == "1st column headername")
{
sortexpression = "1st column headername";
}
if (lnkbtn.Text == "2ndcolumn headername")
{
sortexpression = "2ndcolumn headername";
}
fillgrid();
(i think u know what to write in this function here just bind ur grid and one more thing in this function call the sort function with required paramts mentioned above)
deepti
|
|
|
|
|
|
Change the allowSorting datagrid property to true
go to Columns property, select the field what you want to sort, write onto the SortExpression the same column datafield.
On datagrid sorting function
<br />
protected void Grid_Sorting(object sender, GridViewSortEventArgs e)<br />
{<br />
string sql = "SELECT * FROM table WHERE conditions ORDER BY " + e.SortExpression;<br />
SqlDataAdapter data_Adapter = new SqlDataAdapter(sql, conexxxion);<br />
DataSet dataSet = new DataSet();<br />
data_Adapter.Fill(dataSet);<br />
Grid.DataSource = dataSet.Tables[0].DefaultView;<br />
Grid.DataBind();<br />
}<br />
you can do it with all datagrid columns
keep Learning and you never will be out of date...
|
|
|
|
|
hai friends
im doing asp web application project using c#.net.first step in that is registration form.it will contain username,emailid and country. u fill that form and click submit button.the output is automatically generate the password and pass the your username and password through entered emilid of user.this and all i done.if the user not use the password and username within 24 hours, that record should be detele automatically, how can i do that, can anyone help me
thanks
Dhatchinamoorthy.R
9894824838
|
|
|
|
|
There needs to be some scheduler service that runs in the webserver, which needs to do these maintenance jobs.
|
|
|
|
|
I want to upload image file(only .jpg, .gif, .png) on server.
But according to requirement I've to use image button to browse file.
After selecting file, on "Save Changes" button i've to upload image to server
I'm not able to display File dialog on click event of ImageButton.
Please Help..! I'm new in the .Net.
Thanks In Advance...!
|
|
|
|