|
Can anybody tell me how to Custom Paging in GridView
......
|
|
|
|
|
plz refer to 4GuysFromRolla.com
you will find a very nice article on this.
Rocky
Success is a ladder which you can't climb with your hands in your pockets.
|
|
|
|
|
Hi!
How can I open a gridview in edit mode?
Normally if you open a website the gridview isn’t in edit mode. You can edit a row in gridview by clicking on edit button (edit link).
What I want is to open a website (with a grid) and all of the rows are in edit mode. You can edit a column and click on refresh or save.
Thanks in advance!
Best regards
Klaus
|
|
|
|
|
hi Klaus!
I think if you're using TemplateFields in GridView then you can put all the rows by default in edit mode. Actually there is a property called EditIndex. when you set it to a certain row number it changes itself to the edit template. so this is related to a single row you know. Since you want all the rows to be in edit mode. you need to craft this yourself by adding the text boxes etc
I hope it helps you
Thanks
Rocky
Success is a ladder which you can't climb with your hands in your pockets.
|
|
|
|
|
How can I do that? Can you make me an example please?
Tanks in advance!
Best regards
Klaus
|
|
|
|
|
It goes something like this...
Thats only to show the use of Template Fields. You should carry on according to ur req from here
<asp:gridview id="GridView1" autogeneratecolumns="False" runat="server" datasourceid="ObjectDataSource1" horizontalalign="Left" width="205px">
BorderWidth="0px" CellPadding="0" >
<columns>
<asp:templatefield headertext="Refine Search">
<headertemplate>xyz
</headertemplate>
<itemtemplate>
<asp:textbox id="tb1" runat="server" Text='#Eval("DbField")'>
</asp:textbox></itemtemplate>
<footertemplate>
</footertemplate>
</asp:templatefield>
</columns>
</asp:gridview>
Hope that helps
Thanks
Rocky
Success is a ladder which you can't climb with your hands in your pockets.
|
|
|
|
|
Hi,
You can try
//Index of the row to be edited.
GridView1.EditIndex = 0
GridView1.DataBind()
Faraz Shah Khan
MCP, MCAD.Net
Blog
|
|
|
|
|
stupid question:
how can I use it in my grid?
Thanks in advance!
Best regards
Klaus
|
|
|
|
|
hi,
well u can use it like this
on form's load event ...
if you are using C#.net
if (!IsPostBack)
{
GridView1.EditIndex = 0;//assuming that you want to show first row editable
GridView1.DataSource = "Your DataSource";
GridView1.DataBind();
}
Faraz Shah Khan
MCP, MCAD.Net
Blog
|
|
|
|
|
If I use your code, I get an error message, can you tell me why?
Here is my code:
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GridView1.EditIndex = 0;
GridView1.DataSource = "SqlDataSource1";
GridView1.DataBind();
}
}
}
Here is the error message:
System.InvalidOperationException was unhandled by user code
Message="for GridView1 are DataSource and DataSourceID defined. Delete one of them (is translated by me German = English)”
Source="System.Web"
StackTrace:
bei System.Web.UI.WebControls.DataBoundControl.ConnectToDataSourceView()
bei System.Web.UI.WebControls.DataBoundControl.GetData()
bei System.Web.UI.WebControls.DataBoundControl.PerformSelect()
bei System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
bei System.Web.UI.WebControls.GridView.DataBind()
bei _Default.Page_Load(Object sender, EventArgs e) in
....
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
bei System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
bei System.Web.UI.Control.OnLoad(EventArgs e)
bei System.Web.UI.Control.LoadRecursive()
bei System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
Thanks!
Best regards
Klaus
|
|
|
|
|
Hi,
As you have already defined DataSourceID and DataSource try your code like this
GridView1.EditIndex = 0;
GridView1.DataBind();
The error is generated probably because when you have already assinged DataSource and DataSourceID in designer and try to assign DataSource again in code it gives error.
Faraz Shah Khan
MCP, MCAD.Net
Blog
|
|
|
|
|
Datagrid with checkbox using asp.net.so i will select checkbox and the show to datagird datas show in lable,datagrid using paging concept,I need select checkbox in page 1 some datas and then select page 2 in some datas.but i can't any one only.Any body know,tell immediately...and thanks.........
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ldstdateset As New DataSet
Dim lobjdatatier As New TicDataTier
ldstdateset = lobjdatatier.ExecStoredProc("TIC_GET_tTic_MM_Modules", lstrparameter, "Gmdataset")
Me.MyDataGrid1.DataSource = ldstdateset.Tables(0)
Me.MyDataGrid1.DataBind()
End Sub
Private Sub MyDataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles MyDataGrid1.PageIndexChanged
Me.MyDataGrid1.CurrentPageIndex = e.NewPageIndex
Me.MyDataGrid1.DataBind()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer = 0
Dim mySelection As StringBuilder = New StringBuilder
mySelection.Append("Selected Row(s):<hr><br>")
Dim GridItem As DataGridItem
For Each GridItem In MyDataGrid1.Items
Dim myCheckbox As CheckBox = CType(GridItem.Cells(0).Controls(1), CheckBox)
If myCheckbox.Checked = True Then
i = i + 1
mySelection.AppendFormat("{0}<br>", GridItem.Cells(1).Text)
' mySelection.Append("<hr>")
mySelection.AppendFormat("{0}<br>", GridItem.Cells(2).Text)
End If
Next
mySelection.Append("<br>")
mySelection.Append("<hr>")
mySelection.AppendFormat("Total selected Value is: {0}<br>", i.ToString())
Me.Label1.Text = mySelection.ToString.Trim()
End Sub
Private Sub MyDataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles MyDataGrid1.PageIndexChanged
Me.MyDataGrid1.CurrentPageIndex = e.NewPageIndex
Me.MyDataGrid1.DataBind()
End Sub
And once again thanks
regards,
sen.V
|
|
|
|
|
Hi,
what i believe you will be required to create a method that will check the selected rows of the grid view. when the page is changing call that method and store the selected row in a session. on the next page when user select rows repeat the same process. note that the method will not only be called no the page index change but also where there is some post back on the page.
hope it will help.
Faraz Shah Khan
MCP, MCAD.Net
Blog
|
|
|
|
|
My application's session lasts for only 2 or 3 minutes even if I set session timeout to 30 minutes in web.config file.
<system.web>
<sessionState timeout ="30" ></sessionState>
</system.web>
Can anyone tell the reason
|
|
|
|
|
It's hard to tell what is causing the problem. Are you doing anything that will reset the application, like modifying web.config runtime etc ? If yes it will clear all session variables.
|
|
|
|
|
Hi,
Check your session timeout in IIS as well. Follow the path
IIS -> Default Website -> YourWebSite -> (right click) Properties -> (from Tab) ASP.Net -> Edit Configuration -> (from Tab) State Management.
Check the session out time here and try to increase it if it is lesser than 30 mins.
Faraz Shah Khan
MCP, MCAD.Net
Blog
|
|
|
|
|
The Application is fine on the Dev machine, but on the production server it choked on files that have 1KB or more...
I have set the buffer size to 2048
|
|
|
|
|
see this link
http://www.codeproject.com/KB/custom-controls/PSGridView.aspx
I have an ERROR when I click on INSERT for add new row and after click on CANCEL.
I use the button ADD on gridview to inser a new row.
The control insert a new row, and this is an error!
can you welp me to correct this bug?
thanks
Giano
|
|
|
|
|
zio_pino wrote: see this link
Yes, I can see it.
Abandon hope all ye who answer here.
Pete O'Hanlon - the General Discussions forum
|
|
|
|
|
Has everyone see this problem?
|
|
|
|
|
hi, i'm posting because i have a problem i can't manage to solve...
i have a page with a row of DropDownLists, and what i want to do is this: when the user selects a value from one of the dropdowns , a new one is created under the selected, with the same values of the previous one, except for the selected one.
i know i have to write a function in c# called from OnSelectedIndexChange, but i can't understand how to create the new ddl from the code..
can anyone one help me or suggest a better way to do that?
i'm working on Visual web Developer using C#
thanks anyway, and sorry for the poor english..
bye
Kontax
|
|
|
|
|
If the second drop down has all the same value, minus the one selected you should be using a multi-select box instead of a select drop down. Then the user can select multiple choices w/o going back and forth between the server and w/o the complexity you're talking about.
If you're doing this to limit the number of choices the user makes, you could do this in javascript. Then on the server-side, validate the data a second time to make sure the user didn't try and bypass your client-side script.
|
|
|
|
|
Yes, the second one should have the same values except for the previously selected one. The problem is that after the first selection made with the DropDownList, the user can chose, for the selected value, properties from another DDL, and then another value for this one. So, when the user opens the page, he see a row of DDL. I need that, after the row he finish fulling it, another raw is created under the existing one, and so on, and only the mix of choises done before couldnt be re-done after...
That's the reason why I can't use a multi-select box..
I hope I explaned it well..
About javascript:i'm not used to it, do you really think I can do what I need better using javascript?
how could i do it?
Thanks anyway for the reply
|
|
|
|
|
Sounds like I didn't understand what it is you are trying to do. To clarify, it sounds like you are trying to allow the user to fill out a row of DDL. And then AFTER they have completed that row you want to give them a new row of DDL controls, minus the value(s) from the previous row.
If this is the case, then I recommend that when the user has completed the current row you will allow them to submit those changes to the server. You could use the SelectedIndexChanged of the last DDL of the row, or a command button.
When the user submits the selected values, create a new row in your data source and then rebind your Grid or list (whichever you are using) with the updated data source.
Here's an blog post on using the GridView's footer template to insert new rows: http://geekswithblogs.net/casualjim/articles/51360.aspx[^]. Just put all your DDLs into the footer row and proceed as I recommended above.
If your data source isn't meant to actually update a database or some other persisted store, but is just transient form data for some operation then instead of updating a persisted store you can maintain the data source in a session variable until the user has completed their operation. Then clear out the session variable when you are done.
|
|
|
|
|
Sir,
I m adding texbox in grid at runtime . it added successfully
but my problem is that how to read a value in a texbox i m sending
my code plz check this code give me reply
SqlDataAdaptor da=new SqlDataAdaptor("Select * from mytable",MyConnectionString);
DataSet dtSet=new DataSet();
da.Fill(dtSet);
GridView1.DataSource=dtSet.Table[0];
GridView1.DataBind();
TextBox txt ;
string strID;
//Add Textbox in a grid
for (int i = 0; i < dtSet.Tables[0].Rows.Count; i++)
{
for (int j = 0; j < dtSet.Tables[0].Columns.Count; j++)
{
txt = new TextBox();
strID = i.ToString()+j.ToString();
txt.ID=strID;
GridView1.Rows[0].Cells[0].Controls.Add(txt);
}
}
//Read This TextBox Value
string strTextID;
for (int i = 0; i <GridView1.Rows.Count ; i++)
{
for(int j=0;j<GridView1.Columns.Count;j++)
{
strTextID=i.ToString()+j.ToString();
TextBox txt = (TextBox)GridView1.Rows[i].Cells[j].FindControl(strTextID);
string strText=Txt.Text;//This Statement Give me error
}
}
plz send me reply
Thanks & Regards
Lav Naphade
lav naphade
|
|
|
|