|
protected void Page_Load(object sender, EventArgs e)
{
CreateTextBoxes();
}
public void CreateTextBoxes()
{
int Count = 0;
foreach (DataRow row in dataSetselectactivities.Tables[0].Rows)
{
Count += 1;
lb = new Label();
tb = new TextBox();
tb.Id = "txt_" + Count;
lb.Text = row["field"].ToString();
tb.Text = row["field"].ToString();
RequiredFieldValidator reqv = new RequiredFieldValidator();
reqv.ControlToValidate = tb.Id;
reqv.ErrorMessage = "Err_Msg";
TextBoxesHere.Controls.Add(lb);
TextBoxesHere.Controls.Add(tb);
TextBoxesHere.Controls.Add(reqv);
}
}
string FifthTexBoxValue = ((TextBox)this.Page.FindControl("txt_5")).Text;
regards
Khan
please don't forget to vote on the post that helped you.
|
|
|
|
|
thanks for the reply.
but one thing, surely if i dont know how many textboxes there are then i cant do the following
Imran Khan Pathan wrote: string FifthTexBoxValue = ((TextBox)this.Page.FindControl("txt_5")).Text;
because I wont know if its called txt_5 or not, or am i misunderstanding what your saying?
|
|
|
|
|
.netman wrote: but one thing, surely if i dont know how many textboxes there are then i cant do the following
Yes.I just gave you an example.
Look at this code
int Count=1;
foreach (DataRow row in dataSetselectactivities.Tables[0].Rows)
{
string textboxValue= ((TextBox)this.Page.FindControl("txt_" + Count.ToString())).Text;
Count+=1;
}
by using above code, you can get all textbox value
regard
kHan
please don't forget to vote on the post that helped you.
|
|
|
|
|
Hai all,
i have facing a problem while navigating to paging in datalist.
i take 10 records for a page.it will display exact 10 records for the first time.
if i click second page then it will disply 13 records (3 records from the first page last) and
if i click 1 page fgrom 3rd page then also the records in the first page will be 13...
pls help me..through any suggestions
Thanks
Subbu.
|
|
|
|
|
Are you using custom paging or your own code for pageing, if its your own code please post
|
|
|
|
|
hi.. thanks for ur immediate reply..
pls check this
oncommand=NavigatePage
Protected Sub NavigatePage(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
Select Case e.CommandName
Case "PageNumber"
fintCurrentPage = Convert.ToInt32(e.CommandArgument)
Dim strselection As String = ""
strselection = SearchString
If SearchRange.Length > 0 And strselection.Length > 0 Then
strselection = strselection & " and " & SearchRange
ElseIf SearchRange.Length > 0 Then
strselection = SearchRange
End If
dsPros = getProList(strselection, SortString, fintCurrentPage, PAGE_SIZE)
Dim intNoOfRecs As Int32 = 0
Dim intTotPages As Int32 = 0
intNoOfRecs = CType(dsPros.Tables(1).Rows.Count, Int32)
intTotPages = CType(dsPros.Tables(0).Rows(0).Item(0), Int32)
FormatNavigationMenuBar(fintCurrentPage, intTotPages, PAGE_SIZE, RECS_IN_LIST)
dtlstPros.DataSource = dsPros.Tables(1)
dtlstPros.DataBind()
dtlstPros.UpdateAfterCallBack = True
'' lblListStatus.Text = "Displaying " & (((fintCurrentPage - 1) * PAGE_SIZE) + 1).ToString & " to " & ((fintCurrentPage - 1) * PAGE_SIZE) + intNoOfRecs.ToString & " of " & intTotPages.ToString & " matches"
lblListStatus.UpdateAfterCallBack = True
End Select
End Sub
Protected Function FormatNavigationMenuBar(ByVal CurrentPageNo As Integer, ByVal TotalNoOfRecords As Integer, _
ByVal MaxNoOfProductsOnAPage As Integer, ByVal ForwardNumber As Integer) As String
Dim intStartPageNo As Integer
Dim intPageCounter As Integer
Dim MaxNoOfBrowseToPageLinksOnAPage As Int32
MaxNoOfBrowseToPageLinksOnAPage = ForwardNumber
Dim intTotalPages As Integer
Dim objdtPageLink As New DataTable("PageLink ")
Dim drPageLink As DataRow
With objdtPageLink.Columns
.Add("PageNumber", System.Type.GetType("System.String"))
.Add("PageID", System.Type.GetType("System.String"))
End With
'Compute Total No. of Pages
intTotalPages = CInt(Math.Ceiling(TotalNoOfRecords / MaxNoOfProductsOnAPage))
'>> Finding Starting of series
If (CurrentPageNo Mod MaxNoOfBrowseToPageLinksOnAPage) = 0 Then
intStartPageNo = (CurrentPageNo + 1) - MaxNoOfBrowseToPageLinksOnAPage
Else
intStartPageNo = (CurrentPageNo - (CurrentPageNo Mod MaxNoOfBrowseToPageLinksOnAPage))
If intStartPageNo = 0 Then
intStartPageNo = 1
Else
intStartPageNo += 1
End If
End If
'<<
'>> Form Move Previous link
If Not CurrentPageNo = 1 Then
imgbtnTopMovePrev.ImageUrl = strZoominImgServer + "/images/Pro/Prev_Page.gif"
imgbtnTopMovePrev.CommandArgument = (CurrentPageNo - 1).ToString
imgbtnTopMovePrev.Visible = True
Else
imgbtnTopMovePrev.Visible = False
End If
'<<
'>> Form Move Previous n Pages link
If intStartPageNo > 1 Then
'imgbtnTopMoveFirst.ImageUrl = "~/images/Pro/Firstpage.gif"
lnkbtnTopMoveFirst.CommandArgument = (intStartPageNo - MaxNoOfBrowseToPageLinksOnAPage).ToString
lnkbtnTopMoveFirst.Visible = True
panTopMoveFirst.Visible = True
Else
lnkbtnTopMoveFirst.Visible = False
panTopMoveFirst.Visible = False
'drPageLink = objdtPageLink.NewRow
'drPageLink(0) = "<<"
'drPageLink(1) = (intStartPageNo - MaxNoOfBrowseToPageLinksOnAPage).ToString
'objdtPageLink.Rows.Add(drPageLink)
'objdtPageLink.AcceptChanges()
End If
'>> Form Page Links
For intPageCounter = intStartPageNo To (intStartPageNo + MaxNoOfBrowseToPageLinksOnAPage) - 1
If intPageCounter > intTotalPages Then Exit For
drPageLink = objdtPageLink.NewRow
drPageLink(0) = intPageCounter.ToString
drPageLink(1) = intPageCounter.ToString
objdtPageLink.Rows.Add(drPageLink)
objdtPageLink.AcceptChanges()
Next
'<<
'>> Form Move Next n Pages link
If (intStartPageNo + MaxNoOfBrowseToPageLinksOnAPage) <= intTotalPages Then
'imgbtnTopMoveLast.ImageUrl = "~/images/Pro/lastpage.gif"
lnkbtnTopMoveLast.CommandArgument = (intStartPageNo + MaxNoOfBrowseToPageLinksOnAPage).ToString
lnkbtnTopMoveLast.Visible = True
panTopMoveLast.Visible = True
Else
lnkbtnTopMoveLast.Visible = False
panTopMoveLast.Visible = False
'drPageLink = objdtPageLink.NewRow
'drPageLink(0) = ">>"
'drPageLink(1) = (intStartPageNo + MaxNoOfBrowseToPageLinksOnAPage).ToString
'objdtPageLink.Rows.Add(drPageLink)
'objdtPageLink.AcceptChanges()
End If
'<<
'>> Form Move Next link
'If Not (CurrentPageNo = intTotalPages) Then
If (CurrentPageNo < intTotalPages) Then
imgbtnTopMoveNext.ImageUrl = strZoominImgServer + "/images/Pro/Next_Page.gif"
imgbtnTopMoveNext.CommandArgument = (CurrentPageNo + 1).ToString
imgbtnTopMoveNext.Visible = True
Else
imgbtnTopMoveNext.Visible = False
End If
'<<
If objdtPageLink.Rows.Count = 0 Then
drPageLink = objdtPageLink.NewRow
drPageLink(0) = 1
drPageLink(1) = 1
objdtPageLink.Rows.Add(drPageLink)
objdtPageLink.AcceptChanges()
End If
dtlstTopNavigation.DataSource = objdtPageLink
dtlstTopNavigation.DataBind()
dtlstTopNavigation.UpdateAfterCallBack = True
imgbtnTopMoveNext.UpdateAfterCallBack = True
imgbtnTopMovePrev.UpdateAfterCallBack = True
lnkbtnTopMoveFirst.UpdateAfterCallBack = True
panTopMoveFirst.UpdateAfterCallBack = True
panTopMoveLast.UpdateAfterCallBack = True
lnkbtnTopMoveLast.UpdateAfterCallBack = True
TotalProsListed = TotalNoOfRecords
Return ""
End Function
#End Region
Thanks
Subbu.
|
|
|
|
|
is there any other possible way to bindgrid other than datasource = dataset;
datasource = datatable; datasource = arraylist; and any other
Bharani
|
|
|
|
|
What you are trying to do?
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
Yes ofcourse you can.
We can bind collections, such as Arraylists, Generic collections ie: anything that implements IEnumberable such as List<employee> and also DataTables, DataSets, can be directly assigned to the DataSource property of Data Controls such as GridViews, DataLists.
Thx,
Gayani
|
|
|
|
|
Hi
i have a form which has only employee number textbox and button when the user enter employee number it search the employee number from database and if the employee is found it must display employee details to another form which has all textboxes like names,surname,regionname.etc.I have search functionality which only works if i use one form so i must use two forms one for search and one for displaying
Mamphekgo
|
|
|
|
|
You just need to specify in your onclick event where you want the results to appear. You could use a panel for example and make it visible when you get the results.
This is not that hard to do.
|
|
|
|
|
Hi,
I have a gridview that has an xml datasource. When I click on the edit link next to a record then the fields are displayed in edit mode. There is a drop down list (in the edit mode) as well displaying all the store locations. The store locations are also populated from another xml datasource.
Here is my StoreLocators.xml file (which populates the gridview):
<Deposits>
<Deposit StoreLocator="Shoprite Paarl" DepositID="1" ClientCITNo="G32428932" BranchNo="300932" />
</Deposits>
Here is my StoreLocators.xml file:
<StoreLocators>
<StoreLocator StoreLocatorID="ShopriteAlberton" StoreLocatorName="Shoprite Alberton" />
<StoreLocator StoreLocatorID="ShopriteBloemfontein" StoreLocatorName="Shoprite Bloemfontein" />
<StoreLocator StoreLocatorID="ShopritePaarl" StoreLocatorName="Shoprite Paarl" />
</StoreLocators>
I populate the dropdown like this:
protected void rgDeposits_ItemCreated(object source, GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
DropDownList ddl = (DropDownList)e.Item.FindControl("rcStoreLocators");
ddl.DataSource = dsStoreLocators;
ddl.DataTextField = "StoreLocatorName";
ddl.DataValueField = "StoreLocatorID";
}
}
<EditItemTemplate>
<asp:DropDownList ID="rcStoreLocators" SelectedValue='<%# Eval("StoreLocatorID")%>' runat="server" />
</EditItemTemplate>
Error that I get:
DataBinding: 'System.Web.UI.WebControls.XmlDataSourceNodeDescriptor' does not contain a property with the name 'StoreLocatorID'.
So when the row goes into edit mode, I need the Shoprite Paarl to be selected as the default value. How do I do this?
Thanks
Brendan
<div class="ForumMod">modified on Wednesday, July 9, 2008 6:18 AM</div>
|
|
|
|
|
Can you set the value to 0 in the .net code
|
|
|
|
|
Where do you want me to set this code?
|
|
|
|
|
In your c# when the dropdownlist is created
|
|
|
|
|
Check the original message I changed it. Please help with some C# code.
|
|
|
|
|
check this out it shows how to bind to a radiobuttonlist which is basically the same as binding to a dropdown
http://www.w3schools.com/aspnet/aspnet_xml.asp
|
|
|
|
|
Hi,
I am redirecting my page with query string (UserId is passed as query string). User 'A' has the rights to access the new page. He enterred into that page and he does access. UserId of 'A' is passed as query string. He do not change the query string at the address bar. Now, 'A' can access the page by giving other User's Id after entering into this page. I want to make that address bar as read only after loading this page.
Is it possible?.
By mean time, I am checking the user id in the page load itself, if it false, I am redirecting into main page. Pls help.
Balasubramanian K.
|
|
|
|
|
You cant make the url bar read only, you could hide it and open a new window without it showing but the user can still find a way to by pass this. Best to not show the query string at all in the URL and to hide it instead.
There are lots of articles on hiding query string values when trasnferring them via url
|
|
|
|
|
Thank you for your reply.
Balasubramanian K.
|
|
|
|
|
How to hide the query string? I've read that this is the main disadvantage of qry string. Otherwise, Qry string should be encrypted and decrypted. I dont have any other idea. If u know that how to hide or If you have any articles link, Pls send me...tnx in adv.
Balasubramanian K.
|
|
|
|
|
If the information you are hiding is sensitive then its best to just use sessions
|
|
|
|
|
BalasubramanianK wrote: Now, 'A' can access the page by giving other User's Id after entering into this page. I want to make that address bar as read only after loading this page.
You can't make the address bar read only as ASP.NET don't have any control over the programs installed on the client machine. Your best bet is to validate the query string before processing.
I assume you are keeping currently logged in users id in session named "id". So in the page load check current user is authorized to see this page, something like
if(Session["id"] != NULL && Session["id"].ToString() != Request.QueryString["id"])
{
Response.Redirect("NotAuthorized.aspx");
} The above code will redirect to "NotAuthorized.aspx" if the id passed is not the current user. So user "A" can't pass some other id to see their details.
If you have many pages like this, I would prefer to create a base class and derive all your pages from it. So the checking can be automated.
|
|
|
|
|
i am working on Active director multiple domain for search user.but Its produced Error:- There is no such object on the server. -2147016656
Please Help me.
Code:-
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
FindUser("dev\t", True)
End Sub
Public Function FindUser(ByVal principalname As String, ByVal useGC As Boolean) As DirectoryEntry
Try
Dim searchRoot As DirectoryEntry
Dim searcher As DirectorySearcher
Dim name() As String
Dim ncName As String
name = principalname.Split("\")
If name.Length <> 2 Then
Throw New ArgumentException("principalname is not in the correct format", principalname)
End If
ncName = ResolveNetBiosNameToDN(name(0))
searchRoot = GetDirectoryEnTry(ncName, useGC)
searcher = New DirectorySearcher(searchRoot, String.Format("(&(objectCategory=person)?(objectClass=user)? (sAMAccountName={0}))", name(1)), New String() {"distinguishedName"}, SearchScope.Subtree)
Try
Return searcher.FindOne().GetDirectoryEntry()
Catch ex As NullReferenceException
Throw New ArgumentException("The given username was not found", "principalname", ex)
End Try
Catch ex As Exception
End Try
End Function
Private Function ResolveNetBiosNameToDN(ByVal netbiosName As String) As String
Try
Dim authenticationType As New System.DirectoryServices.AuthenticationTypes
If ConfigurationManager.AppSettings("AD_UseSecureConnection").ToUpper.Trim.Equals("TRUE") Then
authenticationType = AuthenticationTypes.Secure
Else
authenticationType = AuthenticationTypes.None
End If
Dim rootDSE As New DirectoryEntry(ConfigurationManager.AppSettings("AD_IP").Trim, ConfigurationManager.AppSettings("AD_UserName").Trim, ConfigurationManager.AppSettings("AD_Password").Trim, authenticationType)
' Dim configurationNamingContext As String = CType(rootDSE.Properties("configurationNamingContext").Value, String)
Dim defaultNamingContext As String = CType(rootDSE.Properties("distinguishedName").Value, String)
'defaultNamingContext = defaultNamingContext.Split(",")(0)
' Dim Str As String =
Return CType(GetDirectoryEnTry(String.Format("CN={0}, CN=Partitions, {1}", netbiosName, defaultNamingContext)).Properties("nCName").Value, String)
' Return DirectCast(GetDirectoryEnTry(String.Format("CN={0}, CN=Partitions, {1}", netbiosName, DirectCast(configurationNamingContext.Properties("distinguishedName").Value, String))).Properties("nCName").Value, String)
'Dim ss As String = "sada"
Catch ex As System.Runtime.InteropServices.COMException
If CInt(ex.ErrorCode) = 2147950640 Then
Throw New ArgumentException("The given netbios name was invalid", "netbiosName", ex)
Else
Throw
End If
Catch ex As Exception
' return (string) GetDirectoryEntry(string.Format("CN={0}, CN=Partitions, {1}", netbiosName, (string) ConfigurationNamingContext.Properties["distinguishedName"].Value)).Properties["nCName"].Value;
End Try
End Function
Public Function GetDirectoryEnTry(ByVal distinguishedName As String) As DirectoryEntry
Return GetDirectoryEnTry(distinguishedName, False)
End Function
Public Function GetDirectoryEntry(ByVal distinguishedName As String, ByVal useGC As Boolean) As DirectoryEntry
Try
Dim path As String
path = IIf((useGC), "GC://", "LDAP://")
Dim _server As String = "dev.eventure.biz"
If _server IsNot Nothing Then
path += _server
End If
If (Not path.EndsWith("/")) AndAlso (distinguishedName <> "") Then
path += "/"
End If
path += distinguishedName
If path.EndsWith("//") Then
path = path.Remove(path.Length - 2, 2)
End If
Return New DirectoryEntry(path, "dev\adadmin", "password_1234", AuthenticationTypes.Secure)
Catch ex As Exception
End Try
End Function
Thanks
Piyush Vardhan Singh
p_vardhan14@rediffmail.com
http://holyschoolofvaranasi.blogspot.com
http://holytravelsofvaranasi.blogspot.com
|
|
|
|
|
I have a gridview that has some prices that is dispayed as strings.
In the database these prices are nvarchar datatype.
I need to sort them in the gridview as numbers because they are not sorted correctly as strings but at the moment I can't change this datatype in the database. So is there any workaround to sort this column as numbers? how?
|
|
|
|